type Props = {
loading: boolean,
posts: PostNode,
loadMoreEntries: () => PostFeed,
showActionSheetWithOptions: () => Function,
deletePost: (postId: string) => PostNode,
}
type State = {
selectedIndex: number,
}
class Discussions extends Component {
props: Props;
state: State;
constructor(props: Props) {
super(props);
this.keyword = '';
this.state = {
selectedIndex: 1,
};
}
...
在这种情况下,我指的是构造函数中的this.keyword
,Component上的属性既不是道具也不是状态。
答案 0 :(得分:1)
props: Props;
state: State;
是state
和props
的注释。您可以使用keyword
以相同的方式注释keyword: string;
。