I have a simple question for React experts.
I'm currently working on a React project and I need to optimize the display time. For that, I'm trying to delete all the useless renders of the components.
I have started to use React Dev Tool "Profiler". When recording one of my components called , it indicates 2 renders. But if I put a console.log in this component just before the "return", it appears 15 times !
So I don't understand :
- on one side, I'm told the component is only rerendered twice
- on the other side, the console.log appears 15 times in the console
I tried to add one console.log inside the return part, but it appears 15 times too. I can't figure out my misconception of the rendering concept on this point.
Can someone help me with that please ?
Thanks by advance.