In the official documentation for using React with Redux, the documentation seems to always define mapStateToProps
as an anonymous arrow function assigned to a variable:
const mapStateToProps = (state, ownProps) => {
return {
active: ownProps.filter === state.visibilityFilter
}
}
This also seems to be the usage pattern for mapDispatchToProps
and other functions passed to connect
both in the docs and in the community.
It seems it would be much more simple, and follow traditional usage, to define it like so:
function mapStateToProps(state, ownProps) {
return {
active: ownProps.filter === state.visibilityFilter
}
}
Why is this done? Is there a practical reason for this, or is it just preference? Is it frowned upon to use a standard function definition?