我尝试通过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)发布于 2019-11-17 04:30:59
我猜@emotion/native还不支持attrs函数,所以我转而使用styled-components。
https://stackoverflow.com/questions/58894664
复制相似问题