mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7e49a632c2
Summary: Report fast refreshes to the native module that handles reporting Reviewed By: cpojer Differential Revision: D17528523 fbshipit-source-id: 6f8a0b72a18c2d08ab160dc8b6621fce5420a473
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
'use strict';
|
|
|
|
if (__DEV__) {
|
|
const DevSettings = require('../Utilities/DevSettings');
|
|
|
|
if (typeof DevSettings.reload !== 'function') {
|
|
throw new Error('Could not find the reload() implementation.');
|
|
}
|
|
|
|
// This needs to run before the renderer initializes.
|
|
const ReactRefreshRuntime = require('react-refresh/runtime');
|
|
ReactRefreshRuntime.injectIntoGlobalHook(global);
|
|
|
|
const Refresh = {
|
|
performFullRefresh(reason: string) {
|
|
DevSettings.reload(reason);
|
|
},
|
|
|
|
createSignatureFunctionForTransform:
|
|
ReactRefreshRuntime.createSignatureFunctionForTransform,
|
|
|
|
isLikelyComponentType: ReactRefreshRuntime.isLikelyComponentType,
|
|
|
|
getFamilyByType: ReactRefreshRuntime.getFamilyByType,
|
|
|
|
register: ReactRefreshRuntime.register,
|
|
|
|
performReactRefresh() {
|
|
if (ReactRefreshRuntime.hasUnrecoverableErrors()) {
|
|
DevSettings.reload('Fast Refresh - Unrecoverable');
|
|
return;
|
|
}
|
|
ReactRefreshRuntime.performReactRefresh();
|
|
DevSettings.onFastRefresh();
|
|
},
|
|
};
|
|
|
|
(require: any).Refresh = Refresh;
|
|
}
|