【发布时间】:2019-05-09 06:12:36
【问题描述】:
我在我的项目中使用样式化组件。并拥有这个组件
const Title = styled.h1`
font-size: 1.5em;
text-align: center;
color: #000;
`;
我不知道我需要为这个组件添加什么类型 标题:React$ComponentTypeany> 工作,但我认为放任何东西都是坏主意。
我搜索我的问题并找到这个
type StyleValue = {[key: string]: Object} | number | false | null;
type StyleProp = StyleValue | Array<StyleValue>;
但它适用于 react-native,我无法为我的项目更新它
【问题讨论】:
-
由于您已经将
Title初始化为样式化组件,因此您确实需要为其提供类型。您是否尝试为传递给它的道具提供类型定义? -
@BoyWithSilverWings 是的,完全正确,但不确定第二部分,我需要为 Title 和他的道具提供类型定义
标签: react-redux flowtype styled-components