Reviewed By: bhamodi Differential Revision: D33331422 fbshipit-source-id: 016e8dcc0c0c7f1fc353a348b54fda0d5e2ddc01
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {default as HmrClient} from './HMRClient';
|
|
// @ts-ignore
|
|
import {default as ReactRefreshRuntime} from 'react-refresh/runtime';
|
|
|
|
HmrClient.setup(
|
|
'web',
|
|
(window as any).flipperConfig.entryPoint,
|
|
'localhost',
|
|
window.location.port,
|
|
true,
|
|
);
|
|
|
|
ReactRefreshRuntime.injectIntoGlobalHook(window);
|
|
|
|
const Refresh = {
|
|
performFullRefresh(reason: string) {
|
|
console.log('Perform full refresh', reason);
|
|
window.location.reload();
|
|
},
|
|
|
|
createSignatureFunctionForTransform:
|
|
ReactRefreshRuntime.createSignatureFunctionForTransform,
|
|
|
|
isLikelyComponentType: ReactRefreshRuntime.isLikelyComponentType,
|
|
|
|
getFamilyByType: ReactRefreshRuntime.getFamilyByType,
|
|
|
|
register: ReactRefreshRuntime.register,
|
|
|
|
performReactRefresh() {
|
|
if (ReactRefreshRuntime.hasUnrecoverableErrors()) {
|
|
console.error('Fast refresh - Unrecolverable');
|
|
window.location.reload();
|
|
return;
|
|
}
|
|
ReactRefreshRuntime.performReactRefresh();
|
|
console.log('Perform react refresh');
|
|
},
|
|
};
|
|
|
|
// @ts-ignore
|
|
(require as any).Refresh = Refresh;
|
|
|
|
// @ts-ignore
|
|
// eslint-disable-next-line import/no-commonjs
|
|
require('./index.tsx');
|