【问题标题】:React Native - @emotion/native - TextInput placeholder text color attributeReact Native - @emotion/native - TextInput 占位符文本颜色属性
【发布时间】:2020-03-12 15:33:14
【问题描述】:

我正在尝试通过styled.TextInput.attrs 函数传递placeholderTextColor 属性。我这样做的原因是我可以访问主题props

这就是我所拥有的:

const TextInput = styled.TextInput.attrs(props => ({
  placeholderTextColor: "red",
  type: "password"
}))`
  color: ${({ theme }) => theme.colors.text};
`

但我收到以下错误:

_native.default.TextInput.attrs is not a function. (In '_native.default.TextInput.attrs(function (props) {
    return {
      placeholderTextColor: "red",
      type: "password"
    };
  })', '_native.default.TextInput.attrs' is undefined)

【问题讨论】:

  • 你是如何导入你的'styled'的?
  • @AshwinMothilal 像这样:import styled from "@emotion/native"

标签: reactjs react-native expo styled-components emotion


【解决方案1】:

我猜@emotion/native 还不支持attrs 功能,所以我转到styled-components

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2017-05-13
    • 2020-03-27
    • 2019-10-13
    相关资源
    最近更新 更多