Skip to content

Wording Suggests Effects Run Before Commit #7975

@gmoniava

Description

@gmoniava

There is a paragraph from the docs:

Rendering refers to calculating what the next version of your UI should look like. After rendering, Effects are flushed (meaning they are run until there are no more left) and may update the calculation if the Effects have impacts on layout. React takes this new calculation and compares it to the calculation used to create the previous version of your UI, then commits just the minimum changes needed to the DOM (what your user actually sees) to catch it up to the latest version.

See the bold parts. The way this paragraph is written someone may think effects are run before commit, which is not the case.

Why is it confusing?

  1. See how the paragraph initially mentions, "after rendering, effects are flushed" (notice no mention of commit)
  2. Then it says Effects "may update calculation if the Effects have impacts on layout" (this suggests effects can update the render from step 1? no commit mentioned yet).
  3. Then only in the end of the paragraph, it mentions "then commits just the minimum..."

So reader reading this, might think:

render->effects flushed->update calculation (previous render basically) -> commit

Which imho is wrong, at least effects run after commit.

So I think it would be helpful if docs improve this paragraph and make clear what is meant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions