Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/fast-refresh.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ Hooks with dependencies—such as `useEffect`, `useMemo`, and `useCallback`—wi
For example, when you edit `useMemo(() => x * 2, [x])` to `useMemo(() => x * 10, [x])`, it will re-run even though `x` (the dependency) has not changed. If React didn't do that, your edit wouldn't reflect on the screen!

Sometimes, this can lead to unexpected results. For example, even a `useEffect` with an empty array of dependencies would still re-run once during Fast Refresh. However, writing code resilient to an occasional re-running of `useEffect` is a good practice even without Fast Refresh. This makes it easier for you to later introduce new dependencies to it.

Effects may also run again during development for reasons unrelated to Fast Refresh:

- Fast Refresh re-runs Hooks after a code edit, ignoring dependency lists so the changes take effect.
- When [Strict Mode](https://react.dev/reference/react/StrictMode#fixing-bugs-found-by-re-running-effects-in-development) is enabled at the application root, React runs an additional setup and cleanup cycle when a component first mounts to help find missing cleanup.

In both cases, Effects should implement complete cleanup and tolerate being restarted.