How to use the react-refresh/runtime.injectIntoGlobalHook function in react-refresh

To help you get started, we’ve selected a few react-refresh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pmmmwh / react-refresh-webpack-plugin / src / runtime / ReactRefreshEntry.js View on Github external
if (process.env.NODE_ENV !== 'production' && typeof window !== 'undefined') {
  const Refresh = require('react-refresh/runtime');

  // Inject refresh runtime into global
  Refresh.injectIntoGlobalHook(window);

  // Setup placeholder functions
  window.$RefreshReg$ = function() {};
  window.$RefreshSig$ = function() {
    return function(type) {
      return type;
    };
  };

  /**
   * Setup module refresh.
   * @param {number} moduleId An ID of a module.
   * @returns {function(): void} A function to restore handlers to their previous state.
   */
  window.$RefreshSetup$ = function setupModuleRefresh(moduleId) {
    // Capture previous refresh state
github pmmmwh / react-refresh-webpack-plugin / src / utils / ReactRefreshEntry.ts View on Github external
if (process.env.NODE_ENV !== 'production' && typeof window !== 'undefined') {
  const Refresh = require('react-refresh/runtime');
  Refresh.injectIntoGlobalHook(window);
  (window as any).$RefreshReg$ = (): void => undefined;
  (window as any).$RefreshSig$ = () => (type: T) => type;
}