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
2 changes: 2 additions & 0 deletions docs/fast-refresh.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ 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.

Fast Refresh is not the only reason an Effect may run again during development. 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 development-only setup and cleanup cycle to help find missing cleanup. Fast Refresh re-runs Hooks after a code edit, whereas the Strict Mode check can run when a component first mounts. In both cases, Effects should implement complete cleanup and tolerate being restarted.