Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the trigger that caused the update in React 16?

Tags:

I've recently upgraded to fiber. In 15, when a component updates, the update stack trace looks like this

component1Update
...react framework stuff
  component2Update
  ...react framework stuff
    component3Update
    setState
    onClick() <-- Aha!

How do you find the origin of update in Fiber (React 16)?

like image 250
user2167582 Avatar asked Nov 20 '19 00:11

user2167582


1 Answers

I would recommend looking up the node that is being constantly updated in react-profiler, and then decorate that component with https://github.com/welldone-software/why-did-you-render this should tell you why did it update.

like image 156
Lukáš Gibo Vaic Avatar answered Oct 03 '22 21:10

Lukáš Gibo Vaic