How to use react-refresh - 10 common examples

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 parcel-bundler / parcel / packages / transformers / react-refresh-wrap / src / helpers / helpers.js View on Github external
function getRefreshBoundarySignature(exports) {
  var signature = [];
  signature.push(Refresh.getFamilyByType(exports));
  if (exports == null || typeof exports !== 'object') {
    // Exit if we can't iterate over exports.
    // (This is important for legacy environments.)
    return signature;
  }
  for (var key in exports) {
    if (key === '__esModule') {
      continue;
    }
    var desc = Object.getOwnPropertyDescriptor(exports, key);
    if (desc && desc.get) {
      continue;
    }
    var exportValue = exports[key];
    signature.push(key);
    signature.push(Refresh.getFamilyByType(exportValue));
github pmmmwh / react-refresh-webpack-plugin / src / runtime / utils.js View on Github external
function getReactRefreshBoundarySignature(moduleExports) {
  const signature = [];
  signature.push(Refresh.getFamilyByType(moduleExports));

  if (moduleExports == null || typeof moduleExports !== 'object') {
    // Exit if we can't iterate over exports.
    return signature;
  }

  for (var key in moduleExports) {
    if (key === '__esModule') {
      continue;
    }

    signature.push(key);
    signature.push(Refresh.getFamilyByType(moduleExports[key]));
  }

  return signature;
}
github parcel-bundler / parcel / packages / transformers / react-refresh-wrap / src / helpers / helpers.js View on Github external
if (exports == null || typeof exports !== 'object') {
    // Exit if we can't iterate over exports.
    // (This is important for legacy environments.)
    return signature;
  }
  for (var key in exports) {
    if (key === '__esModule') {
      continue;
    }
    var desc = Object.getOwnPropertyDescriptor(exports, key);
    if (desc && desc.get) {
      continue;
    }
    var exportValue = exports[key];
    signature.push(key);
    signature.push(Refresh.getFamilyByType(exportValue));
  }
  return signature;
}
github pmmmwh / react-refresh-webpack-plugin / src / runtime / utils.js View on Github external
function getReactRefreshBoundarySignature(moduleExports) {
  const signature = [];
  signature.push(Refresh.getFamilyByType(moduleExports));

  if (moduleExports == null || typeof moduleExports !== 'object') {
    // Exit if we can't iterate over exports.
    return signature;
  }

  for (var key in moduleExports) {
    if (key === '__esModule') {
      continue;
    }

    signature.push(key);
    signature.push(Refresh.getFamilyByType(moduleExports[key]));
  }

  return signature;
github parcel-bundler / parcel / packages / transformers / react-refresh-wrap / src / helpers / helpers.js View on Github external
function isReactRefreshBoundary(exports) {
  if (Refresh.isLikelyComponentType(exports)) {
    return true;
  }
  if (exports == null || typeof exports !== 'object') {
    // Exit if we can't iterate over exports.
    return false;
  }
  var hasExports = false;
  var areAllExportsComponents = true;
  for (var key in exports) {
    hasExports = true;
    if (key === '__esModule') {
      continue;
    }
    var desc = Object.getOwnPropertyDescriptor(exports, key);
    if (desc && desc.get) {
      // Don't invoke getters as they may have side effects.
github pmmmwh / react-refresh-webpack-plugin / src / runtime / utils.js View on Github external
moduleExports === undefined ||
    moduleExports === null ||
    typeof moduleExports !== 'object'
  ) {
    // Exit if we can't iterate over the exports.
    return;
  }

  for (var key in moduleExports) {
    // Skip registering the Webpack ES Module indicator
    if (key === '__esModule') {
      continue;
    }

    var exportValue = moduleExports[key];
    if (Refresh.isLikelyComponentType(exportValue)) {
      var typeID = moduleId + ' %exports% ' + key;
      Refresh.register(exportValue, typeID);
    }
  }
}
github pmmmwh / react-refresh-webpack-plugin / src / runtime / utils.js View on Github external
function isReactRefreshBoundary(module) {
  var moduleExports = getModuleExports(module);

  if (Refresh.isLikelyComponentType(moduleExports)) {
    return true;
  }
  if (
    moduleExports === undefined ||
    moduleExports === null ||
    typeof moduleExports !== 'object'
  ) {
    // Exit if we can't iterate over exports.
    return false;
  }

  var hasExports = false;
  var areAllExportsComponents = true;
  for (var key in moduleExports) {
    hasExports = true;
github parcel-bundler / parcel / packages / transformers / react-refresh-wrap / src / helpers / helpers.js View on Github external
return false;
  }
  var hasExports = false;
  var areAllExportsComponents = true;
  for (var key in exports) {
    hasExports = true;
    if (key === '__esModule') {
      continue;
    }
    var desc = Object.getOwnPropertyDescriptor(exports, key);
    if (desc && desc.get) {
      // Don't invoke getters as they may have side effects.
      return false;
    }
    var exportValue = exports[key];
    if (!Refresh.isLikelyComponentType(exportValue)) {
      areAllExportsComponents = false;
    }
  }
  return hasExports && areAllExportsComponents;
}
github pmmmwh / react-refresh-webpack-plugin / src / runtime / utils.js View on Github external
var hasExports = false;
  var areAllExportsComponents = true;
  for (var key in moduleExports) {
    hasExports = true;

    // This is the ES Module indicator flag set by Webpack
    if (key === '__esModule') {
      continue;
    }

    // We can (and have to) safely execute getters here,
    // as Webpack manually assigns harmony exports to getters,
    // without any side-effects attached.
    // Ref: https://github.com/webpack/webpack/blob/b93048643fe74de2a6931755911da1212df55897/lib/MainTemplate.js#L281
    var exportValue = moduleExports[key];
    if (!Refresh.isLikelyComponentType(exportValue)) {
      areAllExportsComponents = false;
    }
  }

  return hasExports && areAllExportsComponents;
}
github pmmmwh / react-refresh-webpack-plugin / src / runtime / utils.js View on Github external
function registerExportsForReactRefresh(module) {
  var moduleExports = getModuleExports(module);
  var moduleId = module.id;

  if (Refresh.isLikelyComponentType(moduleExports)) {
    // Register module.exports if it is likely a component
    Refresh.register(moduleExports, moduleId + ' %exports%');
  }

  if (
    moduleExports === undefined ||
    moduleExports === null ||
    typeof moduleExports !== 'object'
  ) {
    // Exit if we can't iterate over the exports.
    return;
  }

  for (var key in moduleExports) {
    // Skip registering the Webpack ES Module indicator
    if (key === '__esModule') {