I was searching for some react projects examples and i have found some here https://reactjs.org/community/examples.html
One of them is a shopping cart project, i checked the code and i have found something that i could not understand, comparing two arrays in componentWillReceiveProps
method.
I know that comparing two arrays always will return false
and this was the source of confusion, here
https://github.com/jeffersonRibeiro/react-shopping-cart/blob/master/src/components/Shelf/index.js
My problem is in this part
if (nextFilters !== this.props.filters) {
this.handleFetchProducts(nextFilters, undefined);
}
Since filters
is an array as shown in propTypes
.
Everything works well, and this what made me ask the question.
So what is the deal here, is componentWillReceiveProps
is a special method so it can make at least a shallow compare between two arrays or what exactly is happening here???