donavon / hook-flow

A flowchart that explains the new lifecycle of a Hooks component. https://dwe.st/hf
MIT License
2.15k stars 79 forks source link

Question:What does the color on the picture mean ? #7

Open Mark24Code opened 4 years ago

Mark24Code commented 4 years ago

Question:What does the color on the picture mean ?

The colors don't seem to match the ones listed in Chrome's performance panel. So what is the color here saying?

截屏2020-03-15下午6 14 59
paroxyzm commented 3 years ago

I'd like to know too. If the yellow color means "the part handled by the browser", then how can the browser run effects?

Or, what is the mechanism between the browser and React, that tells React that "it's time to run effects because I've painted the screen"?

01abhishekjain commented 3 years ago

I'd like to know about this too.

Maybe @donavon can help? Or point to some resource for further study?

Nurou commented 3 years ago

For anyone else confused, this is how I understand it:

An example: The (component) 'Render' action occurs whenever a component mounts or is updated. However, it does not occur when a component unmounts, hence the faded green background colour in the 'unmount' column. Similarly, 'Run lazy initialisers' only runs when a component first mounts, hence the rich background colour in the mount column, and fade in the case of the other two columns.