Different refresh behavior across Android and iOS on Metro 0.81.1
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
Description
Hey folks, on React Native 0.76.7, Metro version 0.81.1, I'm seeing different refresh behavior across Android and iOS on a clean React Native community CLI app. I'm not sure if this falls within the boundaries of a React native issue or a Metro issue. Starting here because the Metro server itself is the entrypoint into demonstrating the bug. I would be happy to file this elsewhere if it's not actually a Metro concern. Thanks for your consideration and time either way!
Here's a reproducer: https://github.com/coolsoftwaretyler/Metro-Refresh-Reproducer
Here's the most relevant code:
What I expect
If I tap "R" in Metro, I should see the useEffect cleanup function in my logs. Then metro restarts. Then I see the useEffect start message. I would not expect to ever see the AppState change. I would expect the same behavior from Fast Refresh if I update the App.tsx file, since that useEffect hook is in there, and is going to always update, based on my interpretation from the fast refresh docs.
I would expect this behavior to be the same on both Android and iOS.
What happens
On iOS, the behavior works exactly as I expect.
On Android, I see some intermittently different behavior.
When I tap "R" in Metro server: In some cases, I get the useEffect cleanup. In others, I never see it. Very often, I also see AppState report that the state has changed to background.
When I update App.tsx and get a fast refresh: I see the behavior I expect more consistently.
If I add //@refresh reset to the top of the file: no change, but I see the useEffect cleanup more frequently, along with a huge wall of state changes to background after setting it.
Video recording
From the reproducer: https://www.dropbox.com/scl/fi/0wfdxz2dnknb1hyik1rxd/Screen-Recording-2025-02-23-at-2.55.59-PM.mov?rlkey=5g7ml59jrmg4p5l0asrifjylj&st=hxwlcdyb&dl=0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Metro-Refresh-Reproducer and its App.tsx lines 60-70, then reproduce the Metro restart and Fast Refresh behavior on Android and iOS using React Native 0.76.7 and Metro 0.81.1. Compare the useEffect cleanup/start logs with the AppState background events; done means the refresh behavior is consistent across both platforms and matches the stated expectations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100