【发布时间】:2018-11-29 17:14:46
【问题描述】:
我正在尝试将 color 道具添加到 styled-components 包装的 TouchableOpacity 并让流程正确输入。
type TouchableOpacityProps = $PropertyType<Element<TouchableOpacity>, "props">;
type ButtonTouchableProps = { color: string } & TouchableOpacityProps;
const ButtonTouchable: ComponentType<ButtonTouchableProps> = styled.TouchableOpacity`
background-color: ${props => props.color};
`;
但是,我在使用 <ButtonTouchable color="#CCCCCC" /> 时收到此流量警告:
无法创建
ButtonTouchable元素,因为属性color是 在对象类型 [1] 中缺失,但存在于道具 [2] 中。 (参考文献:[1] [2])
【问题讨论】:
标签: react-native flowtype