react / react/react-native-website

Docs: distinguish Fast Refresh effect reruns from Strict Mode checks

Offen Anfängerfreundlich
#5,217 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
MDX
Sterne
2.2k
Forks
6.3k
Ø Merge
11 Std. 37 Min.
Gemergte PRs (30 T.)
19

Beschreibung

Description

The Fast Refresh page correctly explains that Hooks with dependencies update during a refresh and that even an Effect with an empty dependency list can run again after an edit.

A short clarification could help readers distinguish that behavior from React Strict Mode's separate development-only Effect check.

What is the problem?

When Strict Mode is enabled, developers can observe repeated Effect setup and cleanup without having triggered a Fast Refresh. Because both mechanisms occur during development and both reward resilient Effect cleanup, their output is easy to conflate while debugging.

The triggers and behavior are different:

  • Fast Refresh follows a code edit and temporarily ignores dependency lists so the edited Hook logic is applied.
  • Strict Mode independently performs an extra development-only Effect setup and cleanup cycle to reveal missing cleanup.

Without that distinction, a developer may incorrectly attribute every repeated Effect to Fast Refresh.

How can we address it?

Add a short note near the end of “Fast Refresh and Hooks,” using the official React Strict Mode documentation as the primary reference.

Possible wording:

Fast Refresh is not the only reason an Effect may run again during development. When Strict Mode is enabled at the application root, React performs an additional development-only setup and cleanup cycle to help find missing cleanup. Fast Refresh reruns Hooks after a code edit, whereas the Strict Mode check can occur on initial mounting without a file save. In both cases, Effects should implement complete cleanup and tolerate being restarted.

Official reference:
https://react.dev/reference/react/StrictMode#fixing-bugs-found-by-re-running-effects-in-development

I can prepare a small docs-only PR against docs/fast-refresh.md if this distinction belongs on the page.

An optional public exercise illustrating the Strict Mode behavior is:
https://frontendatlas.com/react/trivia/react-strictmode-double-invoke-effects

That exercise is not required for the proposed correction; the official React documentation should remain the primary reference.

Why is it important?

It gives React Native developers a more precise debugging model for repeated subscriptions, requests, logs, and cleanup behavior, without weakening the existing guidance that Effects should be resilient.

Who needs this?

React Native developers using function components and Hooks, especially those diagnosing duplicated development-only Effect output.

When should this happen (use version numbers if needed)?

This is not tied to a specific React Native release. It can be made in the docs/fast-refresh.md source for the next documentation version; any current-version backport can remain a maintainer decision.

Disclosure

I maintain FrontendAtlas, an independent frontend interview-prep project, including the optional exercise linked above. No paid, sponsored, or affiliate placement is being requested. I used AI assistance to draft this issue and reviewed it for technical accuracy before posting.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne in docs/fast-refresh.md in der Nähe des Abschnitts „Fast Refresh and Hooks“ und lies anschließend die verlinkte Referenz zu React Strict Mode. Füge eine kurze Klarstellung hinzu, die Fast Refresh nach einer Codeänderung vom entwicklungsmodusbeschränkten Effect-Setup- und Cleanup-Zyklus von Strict Mode unterscheidet. Die Aufgabe ist abgeschlossen, wenn die Unterscheidung und die Hinweise zum Cleanup klar sind, ohne die bestehende Erklärung zu Fast Refresh zu ändern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
react, react-native
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
1/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Aktiv
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
88/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.