diff --git a/node_modules/react-refresh/cjs/react-refresh-runtime.development.js b/node_modules/react-refresh/cjs/react-refresh-runtime.development.js
index 73748ad..f3c6492 100644
--- a/node_modules/react-refresh/cjs/react-refresh-runtime.development.js
+++ b/node_modules/react-refresh/cjs/react-refresh-runtime.development.js
@@ -128,6 +128,20 @@ function canPreserveStateBetween(prevType, nextType) {
return false;
}
+ if (typeof prevType !== typeof nextType) {
+ return false;
+ } else if (
+ typeof prevType === 'object' &&
+ prevType !== null &&
+ nextType !== null
+ ) {
+ if (
+ getProperty(prevType, '$$typeof') !== getProperty(nextType, '$$typeof')
+ ) {
+ return false;
+ }
+ }
+
if (haveEqualSignatures(prevType, nextType)) {
return true;
}
@@ -167,6 +181,21 @@ function getProperty(object, property) {
}
}
+// Patch to fix bellow issue.
+// https://github.com/facebook/react/issues/30659
+// https://github.com/facebook/react/pull/30660/files
+function registerRefreshUpdate(
+ update,
+ family,
+ shouldPreserveState,
+) {
+ if (shouldPreserveState) {
+ update.updatedFamilies.add(family);
+ } else {
+ update.staleFamilies.add(family);
+ }
+}
+
function performReactRefresh() {
if (pendingUpdates.length === 0) {
@@ -182,6 +211,12 @@ function performReactRefresh() {
try {
var staleFamilies = new Set();
var updatedFamilies = new Set();
+ // TODO: rename these fields to something more meaningful.
+ const update = {
+ updatedFamilies, // Families that will re-render preserving state
+ staleFamilies, // Families that will be remounted
+ };
+
var updates = pendingUpdates;
pendingUpdates = [];
updates.forEach(function (_ref) {
@@ -194,19 +229,34 @@ function performReactRefresh() {
updatedFamiliesByType.set(nextType, family);
family.current = nextType; // Determine whether this should be a re-render or a re-mount.
- if (canPreserveStateBetween(prevType, nextType)) {
- updatedFamilies.add(family);
- } else {
- staleFamilies.add(family);
+ const shouldPreserveState = canPreserveStateBetween(prevType, nextType);
+
+ if (typeof prevType === 'object' && prevType !== null) {
+ const nextFamily = {
+ current:
+ getProperty(nextType, '$$typeof') === REACT_FORWARD_REF_TYPE
+ ? nextType.render
+ : getProperty(nextType, '$$typeof') === REACT_MEMO_TYPE
+ ? nextType.type
+ : nextType,
+ };
+ switch (getProperty(prevType, '$$typeof')) {
+ case REACT_FORWARD_REF_TYPE: {
+ updatedFamiliesByType.set(prevType.render, nextFamily);
+ registerRefreshUpdate(update, nextFamily, shouldPreserveState);
+ break;
+ }
+ case REACT_MEMO_TYPE:
+ updatedFamiliesByType.set(prevType.type, nextFamily);
+ registerRefreshUpdate(update, nextFamily, shouldPreserveState);
+ break;
+ }
}
- }); // TODO: rename these fields to something more meaningful.
- var update = {
- updatedFamilies: updatedFamilies,
- // Families that will re-render preserving state
- staleFamilies: staleFamilies // Families that will be remounted
+ // Determine whether this should be a re-render or a re-mount.
+ registerRefreshUpdate(update, family, shouldPreserveState);
+ }); // TODO: rename these fields to something more meaningful.
- };
helpersByRendererID.forEach(function (helpers) {
// Even if there are no roots, set the handler on first update.
// This ensures that if *new* roots are mounted, they'll use the resolve handler.