Files
flipper/desktop/app/src/init-fast-refresh.tsx
Michel Weststrate 04ec026034 Converted some left-over JavaScript file to TypeScript
Summary: Found some errors in a CI failure originating from a JavaScript file. The horror!

Reviewed By: jknoxville

Differential Revision: D29549998

fbshipit-source-id: 633100ec9a446050bb0c703dcc37e9b132b17198
2021-07-06 01:46:44 -07:00

54 lines
1.3 KiB
TypeScript

/**
* 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.
*
* @format
*/
import {default as HmrClient} from './HMRClient';
// @ts-ignore
import {default as ReactRefreshRuntime} from 'react-refresh/runtime';
HmrClient.setup(
'web',
'/app/src/init-fast-refresh.bundle',
'localhost',
'3000',
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');
},
};
(require as any).Refresh = Refresh;
// eslint-disable-next-line import/no-commonjs
require('./init.tsx');