I have a react native app which uses a datepicker and displays a pie chart which changes depending on the date selected.
Whenever I change the date, I filter out the sessions for the pie chart to display and then I get those sessions from useSelector.
So it looks something like this:
const sessions = useSelector(state => state.user.sessions);
I then display them on my chart:
Every time I change the dates it seems that it rerenders multiple times such as 10 times, or if I keep changing the dates it increasingly rerenders.
I noticed the same behavior on other areas where I use the useSelector as well.
What am I doing wrong? I understand that if the state changes it causes it to rerender but why so many times? What is the alternative for better performance?