See more
This is because JavaScript’s sort() method converts each item in the array into strings and constructs the sequence by comparing each array item based on the UTF-16 code values when there is no callback specified.
sort()
If for example, you want to only re-render your component when there is a change in prop — this would be when you use this method. It receives arguments like…
If for example, you want to only re-render your component when there is a change in prop — this would be when you use this method. It receives arguments like nextProps and nextState which help us decide whether to re-render by doi…