Fast Refresh state reset after editing unrelated UI text
0 reputation · 11 Jun 2024, 14:25 UTC
Developers using React Native Fast Refresh expect that editing UI text unrelated to a component’s state leaves useState values intact. In practice, the state occasionally resets to its initial value after such edits, creating confusion about what actually changed. The inconsistency appears to be influenced by Metro’s module caching, the presence of custom Babel plugins, and variations between React Native releases and Expo managed versus bare workflows. Because the Fast Refresh reconciliation step may fail to map the updated component tree under certain configurations, it is unclear which combination of factors triggers the unintended state reset.
What specific Metro cache conditions cause Fast Refresh to discard useState when only static text is modified? How do custom Babel plugins or non‑default Metro settings interfere with the state‑preservation reconciliation step? Under which React Native version ranges does this behavior become reproducible?