Comparing two arrays in componentWillReceiveProps??
saher-elgendy opened this issue · comments
I am confused about that part
componentWillReceiveProps(nextProps) {
const { filters: nextFilters, sort: nextSort } = nextProps;
if (nextFilters !== this.props.filters) {
this.handleFetchProducts(nextFilters, undefined);
}
}
You are comparing two arrays which always will return false and this would make your condition always true
[1, 2] === [1, 2] // false
Don't you think that it's a bad behaviour in your code???
Haha Thanks! I will review the code and change it, you are totally right.
PR #22 credit goes to @saher-elgendy
@Syed-Saad-Qamar i think every thing is fine now because of your fix . credit goes to you all.
useEffect will solve it too and would be a better practice than deprecated componentWillReceiveProps
@saher-elgendy Thanks for your kindness, yeah definitely we can use useEffect but the entire project I don't see they are using **hooks **, you can create a separate issue for hooks so I will raise a PR for that.
@jeffersonRibeiro could you please review and if there is no issue found merge it.
Thanks
Thanks @saher-elgendy and @Syed-Saad-Qamar !
@all-contributors please add @Syed-Saad-Qamar for code
I've put up a pull request to add @Syed-Saad-Qamar! 🎉
@all-contributors please add @saher-elgendy for bug
I've put up a pull request to add @saher-elgendy! 🎉