【发布时间】:2020-04-28 16:43:56
【问题描述】:
我使用 react-native-community 中的 Slider,该组件具有用于设置样式的独特道具,thumbTintColor,minimumTrackTintColor,maximumTrackTintColor,我需要将样式传递给我的主题提供者。看来我不能将道具传递给这个组件,有人知道实现这一点的方法吗?这就是我现在所拥有的,不幸的是它不起作用。
const StyledSlider = styled(Slider)``
export const SurveySlider = props => {
return (
<StyledSlider
style={{
width: '80%',
height: 40,
alignSelf: 'center'
}}
minimumValue={0}
maximumValue={20}
thumbTintColor={`${props => props.theme.primaryColor}`}
minimumTrackTintColor={`${props =>
props.theme.primaryColor}`}
maximumTrackTintColor={`${props =>
props.theme.primaryColor}`}
onValueChange={value => props.onValueChange(value)}
/>
)
}
【问题讨论】:
-
我无法使用我的主题提供者 ${props=> props.theme.primaryColor}...:(
标签: react-native styled-components