I finished the Freecodecamp Leaderboard challenge but there is a thing bothering me. In the documentation it said that using element.forceUpdate() is not recommended. Without using the forceUpdate() function my element did not re-render even though the state was changed(checked in console.log()). Does React not count reordering of array as a change big enough to re-render or is it somthing else I am doing wrong? This is my code:
Check components/Leaderboard.js
These is my sorting function:
sortByRecent(){
let data = this.state.data;
data.sort((a, b) => b.recent - a.recent);
this.state.data = data;
this.forceUpdate(); // Without this line the elements do not re-render
}