react / react/metro

Different refresh behavior across Android and iOS on Metro 0.81.1

Open
#1,440 4 comments 1 reaction 0 assignees View on GitHub

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:

https://github.com/coolsoftwaretyler/Metro-Refresh-Reproducer/blob/bac325b4588d8fff69c8c6900f6299edc9b7fc21/App.tsx#L60-L70

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.