Sunday, July 9, 2017

ReactJS - If componentWillReceiveProps is not firing, double check the syntax of mapStateToProps

In ReactJS, the first obvious reason for componentWillReceiveProps() not firing is the use of mutable data. However, if that's not the case, you should always double check the form of your mapStateToProps() function.

Here, the first example works as expected, but the second one contains a logical, but not syntax error which can be a problem to find sometimes.



var mapStateToProps=(state)=>({



INCORRECT (not returning anything, just a function declaration):

var mapStateToProps=(state)=>function(){

  return {




No comments:

Post a Comment

PSR-1 and PSR-2 coding standards for PHP

Visual aspects of code play a significant role in raising or drowning developer's productivity. In case that there's too much clutte...