August 2017
Beginner
298 pages
7h 4m
English
In the preceding section, we used the App component to retrieve the data from the server and store it in the Redux store. This means that we no longer need to make any network requests in our Home component. We will simply need to retrieve data from the Redux store.
The Home component does not trigger any Redux actions, hence, we only need to import the connect component from react-redux. In your Home.js file, add the following import statement:
import { connect } from 'react-redux';
Replace the export statement of our Home.js file with the following code:
function mapStateToProps(state) { return { posts: state.posts, loading: state.ajaxCalls.getAllPosts.loading, hasError: state.ajaxCalls.getAllPosts.hasError, };}export default ...Read now
Unlock full access