August 2017
Beginner
298 pages
7h 4m
English
Open your src/Components/Post.js file in VSCode. Our first step is to add the required import statements:
import { connect } from 'react-redux';import { bindActionCreators } from 'redux';
Let's strategize how we will connect this component with Redux:
Now, replace your export statement in Post.js with the following code:
function mapStateToProps(state, ownProps) { return { post: state.posts.find(post => post.id === ownProps.match.params.id), loading: state.ajaxCalls.getAllPosts.loading, hasError: state.ajaxCalls.getAllPosts.hasError, ...Read now
Unlock full access