September 2018
Intermediate to advanced
302 pages
7h 17m
English
In the previous section, we worked with async data again. This data has been pushed to the application's Redux store. We have accessed it numerous times in mapStateToProps functions, for example, in the task list container:
const mapStateToProps = state => ({ tasks: state.tasks.get('entities'), isLoading: state.tasks.get('isLoading'), hasError: state.tasks.get('hasError'), errorMsg: state.tasks.get('errorMsg')});
This one is not looking very ugly, but for the task details page, it already is getting out of control. Consider the following:
// On this page we don't know if tasks are already fetchedconst mapStateToProps = (state, ownProps) => ({ task: state.tasks ? state.tasks .get('entities') .find(task => task.id === ownProps.taskId ...
Read now
Unlock full access