Skip to content

Confusion on Executing Timing of useEffect. #7678

Closed
@DevinJohw

Description

@DevinJohw

Summary

It doesn't require there to be state updates inside Effect when repaint happens before Effect executes.

Page

https://react.dev/reference/react/useEffect#caveats

Details

The orginal sentence is:

Even if your Effect was caused by an interaction (like a click), React may allow the browser to repaint the screen before processing the state updates inside your Effect.

I think what the docs want to express is that browser repainting happens before the code inside Effect executes. It doesn't has to there are state updates inside Effect. The orginal sentence give me an misunderstanding that it happens only when there are state updates inside Effect.

This would be much better:

"Even if your Effect was caused by an interaction (like a click), React may allow the browser to repaint the screen before executing the code in your Effect that responds to state updates."

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions