I have a Matches screen in my React Native app that re-renders one extra time every time I reset the matches state from another screen (e.g., Preferences).
Problem Behavior:
Initially, the screen renders once.
If I navigate to Preferences, reset matches, and come back, it renders one extra time (i.e., 2 times).
If I repeat this, the renders keep increasing:
- 1st reset → 2 renders
- 2nd reset → 3 renders
- 3rd reset → 4 renders, and so on...
What I Have Tried:
- Ensured matches state resets properly in Redux.
- Commented second useFocusEffect and checked (rendering is constant only 2 times )
- Commenting
dispatch(loadMatches());
makes the rendering constant (only 2 times )
Question:
- Why does the render count increase every time I reset the state and return to the screen?
- How can I prevent this unnecessary extra re-render?
Would love to hear your insights. Thanks in advance!