React Native-@ emotion / native-TextInput占位符文本颜色属性

时间:2019-11-16 19:59:20

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

我正在尝试通过placeholderTextColor函数传递styled.TextInput.attrs属性。我这样做的原因是可以访问主题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)

1 个答案:

答案 0 :(得分:0)

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