React Redux
- 容器组件:一个容器查找数据并且渲染它相对应的子组件。相对应 意为 拥有相同名字的组件。比如:
StockWidgetContainer => StockWidget
TagCloudContainer => TagCloud
PartyPooperListContainer => PartyPooperList
2.我们有一个组件
class CommentList extends React.Component { this.state = { comments: [] };
componentDidMount() { fetchSomeComments(comments => this.setState({ comments: comments })); } render() { return ( <ul> {this.state.comments.map(c => ( <li>{c.body}—{c.author}</li> ))} </ul> ); } } |