Redux mapStateToProps and mapDispatchToProps Shorthand
This is a tip to reduce boilerplate when writing redux code.
Here’s a typical implementation of a container:
This is how you can use shorthand and reselect to reduce the amount of code it takes (less code less problems):
- Selectors to grab our data out of reducers.
- Reselect to combine our selectors into a single selector.
- This single selector can be used directly in
- Action creators and
- We don’t declare functions for
mapDispatchToPropssince we know they’re the first arguments to connect.
You can see the code for this example on DylanVann/redux-shorthand-example.
Tweet about this post and it will show here.