【发布时间】: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