user967451
user967451

Reputation:

Is there a way to console log whenever a component is rendered or re-rendered?

I have a suspicion that my React app is re-rendering a lot of components due to some unknown errors in my code. I want to be made aware each time any of my components re-render.

I can go into each component and add a console log at the top of each render method but that would be time consuming since there are a lot of components and I would have to do this each time I add a new one.

Is there any "catch all middle-ware" that can be run right before any React component is about to render/re-render? One that sit's globally in one place and works for all components across the board?

Upvotes: 6

Views: 3518

Answers (2)

why-did-you-update is deprecated, here is the latest lib: @welldone-software/why-did-you-render

Upvotes: 4

Tomasz Mularczyk
Tomasz Mularczyk

Reputation: 36179

Is there any "catch all middle-ware" that can be run right before any React component is about to render/re-render? One that sit's globally in one place and works for all components across the board?

I know about one. why-did-you-update.

Upvotes: 1

Related Questions