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

return value type in prepareUpdate #10904

Closed
dakom opened this issue Sep 28, 2017 · 3 comments
Closed

return value type in prepareUpdate #10904

dakom opened this issue Sep 28, 2017 · 3 comments

Comments

@dakom
Copy link

dakom commented Sep 28, 2017

The official renderers seem to generally return a const of {} in prepareUpdate, for example here: https://github.com/facebook/react/blob/master/src/renderers/art/ReactARTFiberEntry.js#L493

While the tutorial at https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md suggests to return true

What is the nature of the return type from prepareUpdate and how does it affect commitUpdate() ?

@iamdustan
Copy link
Contributor

The DOM renderer is the only one currently using prepareUpdate. It allows React to compute the new props to apply separately from applying the diff (commit). This is useful for pausing and resuming work. The other renderers compute the diff during reconciliation.

It was added in #8607 which has substantially more information on the motivation and use case.

@gaearon gaearon closed this as completed Nov 3, 2017
@gaearon
Copy link
Collaborator

gaearon commented Nov 3, 2017

The other renderers compute the diff during reconciliation.

Not sure what you meant by this—prepareUpdate does fire during reconciliation. We compute updates during reconciliation but don’t commit them yet. This makes it possible to split reconciliation across frames. Then we commit the whole tree at once when it is ready.

@gaearon
Copy link
Collaborator

gaearon commented Nov 17, 2020

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

3 participants