【发布时间】:2017-10-02 12:00:54
【问题描述】:
试图找出将数据处理成 React 组件的方式。
我实际上尝试了这两种方法:
A) 州道
componentWillReceiveProps(nextProps) {
if (!nextProps.allPostsQuery.loading && !nextProps.allPostsQuery.error) {
this.setState({
postList: nextProps.allPostsQuery.allPosts,
})
}
}
render () {
return (
<FlatList data={this.state.postList}>
)
}
B) 道具方式
render () {
return (
<FlatList data={this.props.allPostQuery.data}>
)
}
有什么建议/为什么?
【问题讨论】:
标签: react-native apollo-client