react-native: Hot reloading not working

Description

After setting up new react native project, I’m not able to hot reloading. To push any code changes to simulator, I have to follow this steps:

  • Terminate the metro server.
  • Start the metro server again
  • Run yarn react-native run-ios to deploy latest build to simulator

Version

0.67.3

Output of npx react-native info

`info Fetching system and libraries information…

System:

OS: macOS 12.2

CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz

Memory: 72.04 MB / 16.00 GB

Shell: 5.8 - /bin/zsh

Binaries:

Node: 16.13.1 - /var/folders/wv/hl_2xrbs0_g785yr_mvj3r_w0000gq/T/yarn--1644820056516-0.9598795301282483/node

Yarn: 1.22.17 - /var/folders/wv/hl_2xrbs0_g785yr_mvj3r_w0000gq/T/yarn--1644820056516-0.9598795301282483/yarn

npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm

Watchman: 2022.02.07.00 - /usr/local/bin/watchman

Managers:

CocoaPods: 1.11.2 - /usr/local/lib/ruby/gems/3.0.0/bin/pod

SDKs:

iOS SDK:

  Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3

Android SDK: Not Found

IDEs:

Android Studio: 4.1 AI-201.8743.12.41.7199119

Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild

Languages:

Java: 1.8.0_312 - /usr/bin/javac

npmPackages:

@react-native-community/cli: Not Found

react: 17.0.2 => 17.0.2

react-native: 0.67.2 => 0.67.2

react-native-macos: Not Found

npmGlobalPackages:

*react-native*: Not Found

✨ Done in 3.21s.`

Steps to reproduce

  • Start metro server - yarn react-native start

  • Open another terminal and run - yarn react-native run-ios

  • iOS simulator will open and you’ll see app running

  • Now do any cod changes or text changes and save

  • Reload the metro server by tapping “r” or reload the simultor by cmd+r or shake the iOS device from menu option and choose reload or do all three steps

  • Result - Changes are not reflecting

I need to kill the metro server, then start again then need to run ios build again

Snack, code example, screenshot, or link to a repository

https://user-images.githubusercontent.com/31221440/153813534-61c1be58-4407-47b6-9a9c-576865e77c4d.mov

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 28 (1 by maintainers)

Most upvoted comments

Check enable fast refresh device -> shake -> enable fast refresh

Is there any fix for this?

when I upgraded to react native 0.72.7 hot code reload stopped working. I’m using the simulator so there’s no wifi issues.

rm -rf .git/index.lock Worked for me

Hi, i’m experimenting the same behavior in my app, looks like the connection between the iOS simulator and metro tcp port broke after some minutes.

This occur from the react native 0.65 version in our case.

Reggards

rm -rf .git/index.lock worked for me too.

same with react native prebuild, expo router, and expo 49

This can happen also if your device and computer on not on the same wifi network.

On Mar 25, 2023, at 8:06 AM, 7685 @.***> wrote:

same issue.

— Reply to this email directly, view it on GitHub https://github.com/facebook/react-native/issues/33102#issuecomment-1483846515, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKGJS4FIZMZMSXFV5Y23VTW54CWDANCNFSM5OKQJ2SQ. You are receiving this because you commented.