Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow diagram of component lifecycle. #2184

Closed
jackmahoney opened this issue Sep 12, 2014 · 14 comments
Closed

Flow diagram of component lifecycle. #2184

jackmahoney opened this issue Sep 12, 2014 · 14 comments

Comments

@jackmahoney
Copy link

For new developers such as myself understanding exactly when component functions are called, such as shouldComponentUpdate and render, can be very confusing. I have read http://facebook.github.io/react/docs/component-specs.html many times but have failed to piece together a coherent image.

Is there a more detailed reference that perhaps contains diagrams?

If not it would be a great thing to have. In the meantime I could read the source but I think would benefit others.

Thanks

@chenglou
Copy link
Contributor

There is such a diagram. @zpao

@jackmahoney
Copy link
Author

@chenglou If this diagram could be shared here or put up online on the docs page I think a lot of people would appreciate it.

I'm about to attempt some shouldComponentUpdate optimisations on my components.

@jackmahoney
Copy link
Author

@chenglou @zpao any news on this diagram location?

@zpao
Copy link
Member

zpao commented Sep 19, 2014

@chenglou Can you find me a good place to put it?

@chenglou
Copy link
Contributor

@thechrisproject
Copy link

This would still be appreciated... looks like the referencer of this issue and this issue were both closed but without the discussed resolution. Was that deliberate?

@sophiebits
Copy link
Collaborator

@thechrisproject This issue is still open.

@thechrisproject
Copy link

@spicyj Ah, 951 is closed. Sorry about that! I'm fairly new to using github, I read that 'closed' as 'the state for this issue transitioned to closed here'

@chris-martin
Copy link

Is the diagram real? Just posting it to this issue would be better than nothing.

@chris-martin
Copy link

Here's a quick attempt in case it provides some inspiration... https://gist.github.com/chris-martin/2424924e7a7494d5f98c

@eduardoboucas
Copy link

Here's my take on it, hopefully someone will find it handy: http://codepen.io/eduardoboucas/full/jqWbdb/

@aweary
Copy link
Contributor

aweary commented Mar 7, 2016

@eduardoboucas very cool, love the interactive format!

@bjrmatos
Copy link
Contributor

bjrmatos commented Mar 7, 2016

@eduardoboucas looks very good!

@gaearon
Copy link
Collaborator

gaearon commented Oct 23, 2016

New reference lists lifecycles by phase:

screen shot 2016-10-23 at 14 18 23

I think we can close this.

@gaearon gaearon closed this as completed Oct 23, 2016
josephsavona added a commit that referenced this issue May 15, 2024
See context from #2187 for background about control dependencies. 

Our current `PruneNonReactiveIdentifiers` pass runs on ReactiveFunction, after 
scope construction, and removes scope dependencies that aren't reactive. It 
works by first building up a set of reactive identifiers in 
`InferReactiveIdentifiers`, then walking the ReactiveFunction and pruning any 
scope dependencies that aren't in that set. 

The challenge is control variables, as demonstrated by the test cases in #2184. 
`InferReactiveIdentifiers` runs against ReactiveFunction, and when we initially 
wrote it we didn't consider control variables. To handle control variables we 
really need to use precise control- & data-flow analysis, which is much easier 
with HIR. 

This PR adds the start of `InferReactivePlaces`, which annotates each `Place` 
with whether it is reactive or not. This allows the annotation to survive 
LeaveSSA, which swaps out the identifiers of places but leaves other properties 
as-is. This version does _not_ yet handle control variables, but it's already 
more precise than our existing inference. In our current inference, if `x` is 
ever assigned a reactive value, then all `x`s are marked reactive. In our new 
inference, each instance of `x` (each Place) gets a separate flag based on 
whether x can actually be reactive at that point in the program. 

There are two main next steps (in follow-up PRs): 

* Update the mechanism by which we prune non-reactive dependencies from scopes. 

* Handle control variables. I think we may be able to use dominator trees to 
figure out the set of basic blocks whose reachability is gated by the control 
variables. This should clearly work for if/else and switch, as for loops i'm not 
sure but intuitively it seems right.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests