I'm writing a SPA using Redux to manage my state. There is a logic component connected to the redux store, and it has a child component and it transport the 'posts' state by props to the child component. In the child component's render function:
const {onShow,posts} = this.props;
It works well; just the posts will change with the redux store. But in its componentDidMount() function or construct function the posts will not change with redux store, so how could it happen?
componentDidMount(){
const {posts} = this.props;
console.log(posts)
}
Here are the complete components code. It's about the Lists component and Posts component.
componentWillReceiveProps(nextProps) { console.log(nextProps.posts }- Rei DiencomponentDidMount()only gets fired when the component is... well, mounted (i.e., rendered to the UI). Or such is my interpretation. - IsenrichO