Skip to content

Commit 7a3d9a4

Browse files
committed
fix: import LogBox and DevSettings from public RN interface
1 parent b5995fc commit 7a3d9a4

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

packages/repack/src/modules/WebpackHMRClient.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ interface RNDevSettings {
1010
reload(): void;
1111
}
1212

13-
interface RNLogBoxData {
14-
clear(): void;
13+
interface RNLogBox {
14+
clearAllLogs(): void;
1515
}
1616

1717
class HMRClient {
@@ -153,17 +153,13 @@ class HMRClient {
153153

154154
if (__DEV__ && module.hot) {
155155
const reload = () => {
156-
let DevSettings: RNDevSettings;
157-
if (__REACT_NATIVE_MINOR_VERSION__ >= 79) {
158-
DevSettings =
159-
require('react-native/Libraries/Utilities/DevSettings').default;
160-
} else {
161-
DevSettings = require('react-native/Libraries/Utilities/DevSettings');
162-
}
156+
const DevSettings: RNDevSettings = require('react-native').DevSettings;
163157
DevSettings.reload();
164158
};
165159

166160
const dismissErrors = () => {
161+
const LogBox: RNLogBox = require('react-native').LogBox;
162+
167163
if (__PLATFORM__ === 'ios') {
168164
const NativeRedBox =
169165
require('react-native/Libraries/NativeModules/specs/NativeRedBox').default;
@@ -173,14 +169,8 @@ if (__DEV__ && module.hot) {
173169
require('react-native/Libraries/Core/NativeExceptionsManager').default;
174170
NativeExceptionsManager?.dismissRedbox();
175171
}
176-
let LogBoxData: RNLogBoxData;
177-
if (__REACT_NATIVE_MINOR_VERSION__ >= 79) {
178-
LogBoxData =
179-
require('react-native/Libraries/LogBox/Data/LogBoxData').default;
180-
} else {
181-
LogBoxData = require('react-native/Libraries/LogBox/Data/LogBoxData');
182-
}
183-
LogBoxData.clear();
172+
173+
LogBox.clearAllLogs();
184174
};
185175

186176
const showLoadingView = (text: string, type: 'load' | 'refresh') => {

0 commit comments

Comments
 (0)