react / react/metro

React Native Template does not Reload or Fast Refresh properly

Open
#883 3 comments 2 reactions 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

Do you want to request a feature or report a bug?
Bug

What is the current behavior?

I recently created a new React Native project using the following command: npx react-native init MyProject. This created scaffolding for React Native 0.70.3 and metro 0.72.3. I noticed that after editing the App.js file two times, both the Fast Refresh feature and manually "reloading" the application did not work. I had to kill the metro server and restart it to get the changes to apply.

I created another React Native project specifying the previous version: npx react-native init MyProject_69 --version 0.69.6
and was not able to reproduce this issue: React Native 0.69.6 and metro 0.70.1. Something seems to have broken between 0.70.1 and 0.72.3. I also grabbed the latest snapshot of React Native (at the time was 0.0.0-20221021-2022-9e68eea2c), which points to metro 0.72.3, and verified the issue is still present.

I was able to reproduce this issue just using the plain template with no additional code changes or customizations.

I am fairly confident that the issue is with Metro as I was able to inspect the source payload from Metro after a reload and confirm that the expected code changes were not present in the javascript. In my tests I was using the iPhone 13 simulator running iOS 15.5.

What is the expected behavior?

I expect the behavior of 0.72.3 to be the same as 0.70.1, where any time I make changes to App.js, they are reflected.

I am on an M1 MacBook Pro.

macOS: 12.3
Xcode: 13.4.1
node: v16.15.1
yarn: 1.22.19

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

Reproduce the issue with a project created by npx react-native init MyProject using React Native 0.70.3 and Metro 0.72.3, then compare it with the 0.69.6/Metro 0.70.1 setup. Start with changes to App.js and inspect Metro's source payload after Fast Refresh or a reload; done means edits are reflected without restarting Metro.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
build-system, mobile
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.