You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constFoo({ ... })=>(<div></div>)// Better to name a class instead of using an anonymous function// so it can be debugged easily on devtoolsexportdefaultFoo
Use defaultProps instead of select (mapStateToProps) to assign default values coming in from the store/do null check
You can use defaultProps or select (mapStateToProps) to assign default values. You may need this to avoid unexpected errors b/c of passing undefined.
Prefer defaultProps for this because that's what it's meant for. Keep select to do just one thing: selecting stuff from state.
No:
render(){this.props.list.map(...)// Can skip null check}
...
functionselect(state){return{list: state.list||[]}}exportdefaultconnect(select)(...)
Yes:
staticdefaultProps={list: []};render(){this.props.list.map(...)// Can skip null check}
...
functionselect(state){return{list: state.list}}exportdefaultconnect(select)(...)