我正在尝试通过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)
答案 0 :(得分:0)
我猜@emotion/native
还不支持attrs
功能,所以我移到了styled-components
。