August 2017
Beginner
298 pages
7h 4m
English
The NewPost component requires both state and actions from Redux. It needs the loading and hasError data from state and will have to use postActions to submit a post to the server. So, let's start by including the required import statements in the src/Components/NewPost/NewPost.js file:
import { connect } from 'react-redux';import { bindActionCreators } from 'redux';import * as postActions from '../../redux/actions/postActions';
Now, replace your export statement in the NewPost.js file with the following code:
function mapStateToProps(state) { return { loading: state.ajaxCalls.addPost.loading, hasError: state.ajaxCalls.addPost.hasError, };}function mapDispatchToProps(dispatch) { return { postActions: bindActionCreators(postActions, ...Read now
Unlock full access