Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable `Fast Refresh` in React native on Javascript (not using Developer Menu)

Fast Refresh is broken in some Detox tests and I need to disable it from Javascript, without using the Developer Menu.

Any idea?

like image 860
gusgard Avatar asked Feb 13 '26 17:02

gusgard


1 Answers

Found the answer in the source code

For version 0.61:

import { NativeModules } from 'react-native';

if (__DEV__) {
  const { DevSettings } = NativeModules;
  DevSettings.setHotLoadingEnabled(false);
  DevSettings.setLiveReloadEnabled(false);
}

For version >= 0.62:

import { DevSettings } from "react-native"

if (__DEV__) {
  DevSettings._nativeModule.setHotLoadingEnabled(false);
}

For version >= 0.71:

import { NativeModules } from 'react-native';

if (__DEV__) {
  NativeModules.DevSettings.setHotLoadingEnabled(false);
}
like image 143
gusgard Avatar answered Feb 16 '26 09:02

gusgard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!