I’ve been working with react for nearly 3 years, but sometimes run into difficulties in "Rendering" meaning.
Practically, to check "Rendering", I just put "console.log(‘render’)" in a component right before "return <>…</>". Is this correct check? Or Can’t I know whether it’s re-rendered or not?
4
Answers
Better to use hook
useEffect
and check it insideCheck React Developer Tools and profiler. When turned on, the re rendered components will flash on your screen.
Yes you are right, whenever you see "render" in your logs it means the component is rendering.
What I used to do was declaring a variable outside of the component and and initialize it to 0 then increment it from inside the component so I can know how many times it has rendered
I’m not able to comment yet, but to build on what the answer about the react developer tools:
Best of luck!