1// This needs to run before the renderer initializes. 2 3const ReactRefreshRuntime = require('react-refresh/runtime'); 4ReactRefreshRuntime.injectIntoGlobalHook(global); 5 6const Refresh = { 7 performFullRefresh() { 8 location.reload(); 9 }, 10 11 createSignatureFunctionForTransform: ReactRefreshRuntime.createSignatureFunctionForTransform, 12 13 isLikelyComponentType: ReactRefreshRuntime.isLikelyComponentType, 14 15 getFamilyByType: ReactRefreshRuntime.getFamilyByType, 16 17 register: ReactRefreshRuntime.register, 18 19 performReactRefresh() { 20 if (ReactRefreshRuntime.hasUnrecoverableErrors()) { 21 location.reload(); 22 return; 23 } 24 ReactRefreshRuntime.performReactRefresh(); 25 }, 26}; 27 28// The metro require polyfill can not have dependencies (applies for all polyfills). 29// Expose `Refresh` by assigning it to global to make it available in the polyfill. 30global[(global.__METRO_GLOBAL_PREFIX__ || '') + '__ReactRefresh'] = Refresh; 31