diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index 9f7e914f89a52..3b0c5bccf269e 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -df12d7eac40c87bd5fdde0aa5a739bce9e7dce27 +4cd7065665ea2cf33c306265c8d817904bb401ca diff --git a/compiled/facebook-www/React-dev.modern.js b/compiled/facebook-www/React-dev.modern.js index ca697d73bb3c6..e2a990c3d0e2a 100644 --- a/compiled/facebook-www/React-dev.modern.js +++ b/compiled/facebook-www/React-dev.modern.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-www-modern-bc9d666a"; +var ReactVersion = "18.3.0-www-modern-6995898a"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled/facebook-www/ReactART-dev.classic.js b/compiled/facebook-www/ReactART-dev.classic.js index 8922cfa5435c8..cf85b46878ba5 100644 --- a/compiled/facebook-www/ReactART-dev.classic.js +++ b/compiled/facebook-www/ReactART-dev.classic.js @@ -69,7 +69,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = "18.3.0-www-classic-e1e0fe51"; +var ReactVersion = "18.3.0-www-classic-d297891e"; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -9250,8 +9250,6 @@ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // clean-up function, and we track the deps correctly, we can call pushEffect // directly, without storing any additional state. For the same reason, we // don't need to set a static flag, either. - // TODO: We can move this to the passive phase once we add a pre-commit - // consistency check. See the next comment. fiber.flags |= Passive$1; pushEffect( @@ -9269,18 +9267,22 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // normal rules of React, and only works because store updates are // always synchronous. - var nextSnapshot = getSnapshot(); + var nextSnapshot; { - if (!didWarnUncachedGetSnapshot) { - var cachedSnapshot = getSnapshot(); + nextSnapshot = getSnapshot(); - if (!objectIs(nextSnapshot, cachedSnapshot)) { - error( - "The result of getSnapshot should be cached to avoid an infinite loop" - ); + { + if (!didWarnUncachedGetSnapshot) { + var cachedSnapshot = getSnapshot(); - didWarnUncachedGetSnapshot = true; + if (!objectIs(nextSnapshot, cachedSnapshot)) { + error( + "The result of getSnapshot should be cached to avoid an infinite loop" + ); + + didWarnUncachedGetSnapshot = true; + } } } } @@ -9303,7 +9305,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { if ( inst.getSnapshot !== getSnapshot || - snapshotChanged || // Check if the susbcribe function changed. We can save some memory by + snapshotChanged || // Check if the subscribe function changed. We can save some memory by // checking whether we scheduled a subscription effect above. (workInProgressHook !== null && workInProgressHook.memoizedState.tag & HasEffect) @@ -9645,7 +9647,8 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var effect = hook.memoizedState; - var inst = effect.inst; // currentHook is null when rerendering after a render phase state update. + var inst = effect.inst; // currentHook is null on initial mount when rerendering after a render phase + // state update or for strict mode. if (currentHook !== null) { if (nextDeps !== null) { diff --git a/compiled/facebook-www/ReactART-dev.modern.js b/compiled/facebook-www/ReactART-dev.modern.js index 44c8028828d6e..94e17a9d1193e 100644 --- a/compiled/facebook-www/ReactART-dev.modern.js +++ b/compiled/facebook-www/ReactART-dev.modern.js @@ -69,7 +69,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = "18.3.0-www-modern-f0df93d6"; +var ReactVersion = "18.3.0-www-modern-2f2a7948"; var LegacyRoot = 0; var ConcurrentRoot = 1; @@ -9006,8 +9006,6 @@ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // clean-up function, and we track the deps correctly, we can call pushEffect // directly, without storing any additional state. For the same reason, we // don't need to set a static flag, either. - // TODO: We can move this to the passive phase once we add a pre-commit - // consistency check. See the next comment. fiber.flags |= Passive$1; pushEffect( @@ -9025,18 +9023,22 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // normal rules of React, and only works because store updates are // always synchronous. - var nextSnapshot = getSnapshot(); + var nextSnapshot; { - if (!didWarnUncachedGetSnapshot) { - var cachedSnapshot = getSnapshot(); + nextSnapshot = getSnapshot(); - if (!objectIs(nextSnapshot, cachedSnapshot)) { - error( - "The result of getSnapshot should be cached to avoid an infinite loop" - ); + { + if (!didWarnUncachedGetSnapshot) { + var cachedSnapshot = getSnapshot(); - didWarnUncachedGetSnapshot = true; + if (!objectIs(nextSnapshot, cachedSnapshot)) { + error( + "The result of getSnapshot should be cached to avoid an infinite loop" + ); + + didWarnUncachedGetSnapshot = true; + } } } } @@ -9059,7 +9061,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { if ( inst.getSnapshot !== getSnapshot || - snapshotChanged || // Check if the susbcribe function changed. We can save some memory by + snapshotChanged || // Check if the subscribe function changed. We can save some memory by // checking whether we scheduled a subscription effect above. (workInProgressHook !== null && workInProgressHook.memoizedState.tag & HasEffect) @@ -9401,7 +9403,8 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var effect = hook.memoizedState; - var inst = effect.inst; // currentHook is null when rerendering after a render phase state update. + var inst = effect.inst; // currentHook is null on initial mount when rerendering after a render phase + // state update or for strict mode. if (currentHook !== null) { if (nextDeps !== null) { diff --git a/compiled/facebook-www/ReactART-prod.classic.js b/compiled/facebook-www/ReactART-prod.classic.js index 4f3ab0b09e6fd..ce38314bf9895 100644 --- a/compiled/facebook-www/ReactART-prod.classic.js +++ b/compiled/facebook-www/ReactART-prod.classic.js @@ -2971,12 +2971,12 @@ function updateMutableSource(source, getSnapshot, subscribe) { } function updateSyncExternalStore(subscribe, getSnapshot) { var fiber = currentlyRenderingFiber$1, - hook = updateWorkInProgressHook(), - nextSnapshot = getSnapshot(), - snapshotChanged = !objectIs( - (currentHook || hook).memoizedState, - nextSnapshot - ); + hook = updateWorkInProgressHook(); + var nextSnapshot = getSnapshot(); + var snapshotChanged = !objectIs( + (currentHook || hook).memoizedState, + nextSnapshot + ); snapshotChanged && ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0)); hook = hook.queue; @@ -10193,7 +10193,7 @@ var slice = Array.prototype.slice, return null; }, bundleType: 0, - version: "18.3.0-www-classic-b2a7bab7", + version: "18.3.0-www-classic-06adf47d", rendererPackageName: "react-art" }; var internals$jscomp$inline_1325 = { @@ -10224,7 +10224,7 @@ var internals$jscomp$inline_1325 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-b2a7bab7" + reconcilerVersion: "18.3.0-www-classic-06adf47d" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1326 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled/facebook-www/ReactART-prod.modern.js b/compiled/facebook-www/ReactART-prod.modern.js index 244f896008226..e7b09ea876f9b 100644 --- a/compiled/facebook-www/ReactART-prod.modern.js +++ b/compiled/facebook-www/ReactART-prod.modern.js @@ -2777,12 +2777,12 @@ function updateMutableSource(source, getSnapshot, subscribe) { } function updateSyncExternalStore(subscribe, getSnapshot) { var fiber = currentlyRenderingFiber$1, - hook = updateWorkInProgressHook(), - nextSnapshot = getSnapshot(), - snapshotChanged = !objectIs( - (currentHook || hook).memoizedState, - nextSnapshot - ); + hook = updateWorkInProgressHook(); + var nextSnapshot = getSnapshot(); + var snapshotChanged = !objectIs( + (currentHook || hook).memoizedState, + nextSnapshot + ); snapshotChanged && ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0)); hook = hook.queue; @@ -9858,7 +9858,7 @@ var slice = Array.prototype.slice, return null; }, bundleType: 0, - version: "18.3.0-www-modern-50ab1d1d", + version: "18.3.0-www-modern-899090e3", rendererPackageName: "react-art" }; var internals$jscomp$inline_1305 = { @@ -9889,7 +9889,7 @@ var internals$jscomp$inline_1305 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-50ab1d1d" + reconcilerVersion: "18.3.0-www-modern-899090e3" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1306 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled/facebook-www/ReactDOM-dev.classic.js b/compiled/facebook-www/ReactDOM-dev.classic.js index 3f7f42f8ef448..4b6a1214bc336 100644 --- a/compiled/facebook-www/ReactDOM-dev.classic.js +++ b/compiled/facebook-www/ReactDOM-dev.classic.js @@ -13799,8 +13799,6 @@ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // clean-up function, and we track the deps correctly, we can call pushEffect // directly, without storing any additional state. For the same reason, we // don't need to set a static flag, either. - // TODO: We can move this to the passive phase once we add a pre-commit - // consistency check. See the next comment. fiber.flags |= Passive$1; pushEffect( @@ -13818,18 +13816,33 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // normal rules of React, and only works because store updates are // always synchronous. - var nextSnapshot = getSnapshot(); + var nextSnapshot; + var isHydrating = getIsHydrating(); - { - if (!didWarnUncachedGetSnapshot) { - var cachedSnapshot = getSnapshot(); + if (isHydrating) { + // Needed for strict mode double render + if (getServerSnapshot === undefined) { + throw new Error( + "Missing getServerSnapshot, which is required for " + + "server-rendered content. Will revert to client rendering." + ); + } - if (!objectIs(nextSnapshot, cachedSnapshot)) { - error( - "The result of getSnapshot should be cached to avoid an infinite loop" - ); + nextSnapshot = getServerSnapshot(); + } else { + nextSnapshot = getSnapshot(); - didWarnUncachedGetSnapshot = true; + { + if (!didWarnUncachedGetSnapshot) { + var cachedSnapshot = getSnapshot(); + + if (!objectIs(nextSnapshot, cachedSnapshot)) { + error( + "The result of getSnapshot should be cached to avoid an infinite loop" + ); + + didWarnUncachedGetSnapshot = true; + } } } } @@ -13852,7 +13865,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { if ( inst.getSnapshot !== getSnapshot || - snapshotChanged || // Check if the susbcribe function changed. We can save some memory by + snapshotChanged || // Check if the subscribe function changed. We can save some memory by // checking whether we scheduled a subscription effect above. (workInProgressHook !== null && workInProgressHook.memoizedState.tag & HasEffect) @@ -13875,7 +13888,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { ); } - if (!includesBlockingLane(root, renderLanes$1)) { + if (!isHydrating && !includesBlockingLane(root, renderLanes$1)) { pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); } } @@ -14194,7 +14207,8 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var effect = hook.memoizedState; - var inst = effect.inst; // currentHook is null when rerendering after a render phase state update. + var inst = effect.inst; // currentHook is null on initial mount when rerendering after a render phase + // state update or for strict mode. if (currentHook !== null) { if (nextDeps !== null) { @@ -15443,7 +15457,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -15587,7 +15601,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -15918,7 +15932,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -16085,7 +16099,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -34168,7 +34182,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-b6d18d0e"; +var ReactVersion = "18.3.0-www-classic-340ebf62"; function createPortal$1( children, diff --git a/compiled/facebook-www/ReactDOM-dev.modern.js b/compiled/facebook-www/ReactDOM-dev.modern.js index 8b9adff44c568..19d0f1669cdd5 100644 --- a/compiled/facebook-www/ReactDOM-dev.modern.js +++ b/compiled/facebook-www/ReactDOM-dev.modern.js @@ -13740,8 +13740,6 @@ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // clean-up function, and we track the deps correctly, we can call pushEffect // directly, without storing any additional state. For the same reason, we // don't need to set a static flag, either. - // TODO: We can move this to the passive phase once we add a pre-commit - // consistency check. See the next comment. fiber.flags |= Passive$1; pushEffect( @@ -13759,18 +13757,33 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // normal rules of React, and only works because store updates are // always synchronous. - var nextSnapshot = getSnapshot(); + var nextSnapshot; + var isHydrating = getIsHydrating(); - { - if (!didWarnUncachedGetSnapshot) { - var cachedSnapshot = getSnapshot(); + if (isHydrating) { + // Needed for strict mode double render + if (getServerSnapshot === undefined) { + throw new Error( + "Missing getServerSnapshot, which is required for " + + "server-rendered content. Will revert to client rendering." + ); + } - if (!objectIs(nextSnapshot, cachedSnapshot)) { - error( - "The result of getSnapshot should be cached to avoid an infinite loop" - ); + nextSnapshot = getServerSnapshot(); + } else { + nextSnapshot = getSnapshot(); - didWarnUncachedGetSnapshot = true; + { + if (!didWarnUncachedGetSnapshot) { + var cachedSnapshot = getSnapshot(); + + if (!objectIs(nextSnapshot, cachedSnapshot)) { + error( + "The result of getSnapshot should be cached to avoid an infinite loop" + ); + + didWarnUncachedGetSnapshot = true; + } } } } @@ -13793,7 +13806,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { if ( inst.getSnapshot !== getSnapshot || - snapshotChanged || // Check if the susbcribe function changed. We can save some memory by + snapshotChanged || // Check if the subscribe function changed. We can save some memory by // checking whether we scheduled a subscription effect above. (workInProgressHook !== null && workInProgressHook.memoizedState.tag & HasEffect) @@ -13816,7 +13829,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { ); } - if (!includesBlockingLane(root, renderLanes$1)) { + if (!isHydrating && !includesBlockingLane(root, renderLanes$1)) { pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); } } @@ -14135,7 +14148,8 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var effect = hook.memoizedState; - var inst = effect.inst; // currentHook is null when rerendering after a render phase state update. + var inst = effect.inst; // currentHook is null on initial mount when rerendering after a render phase + // state update or for strict mode. if (currentHook !== null) { if (nextDeps !== null) { @@ -15384,7 +15398,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -15528,7 +15542,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -15859,7 +15873,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -16026,7 +16040,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -34013,7 +34027,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-50ab1d1d"; +var ReactVersion = "18.3.0-www-modern-899090e3"; function createPortal$1( children, diff --git a/compiled/facebook-www/ReactDOM-prod.classic.js b/compiled/facebook-www/ReactDOM-prod.classic.js index 42d1895212405..54ce00ca68201 100644 --- a/compiled/facebook-www/ReactDOM-prod.classic.js +++ b/compiled/facebook-www/ReactDOM-prod.classic.js @@ -3772,16 +3772,20 @@ function updateMutableSource(source, getSnapshot, subscribe) { var hook = updateWorkInProgressHook(); return useMutableSource(hook, source, getSnapshot, subscribe); } -function updateSyncExternalStore(subscribe, getSnapshot) { +function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { var fiber = currentlyRenderingFiber$1, hook = updateWorkInProgressHook(), - nextSnapshot = getSnapshot(), - snapshotChanged = !objectIs( - (currentHook || hook).memoizedState, - nextSnapshot - ); + isHydrating$jscomp$0 = isHydrating; + if (isHydrating$jscomp$0) { + if (void 0 === getServerSnapshot) throw Error(formatProdErrorMessage(407)); + getServerSnapshot = getServerSnapshot(); + } else getServerSnapshot = getSnapshot(); + var snapshotChanged = !objectIs( + (currentHook || hook).memoizedState, + getServerSnapshot + ); snapshotChanged && - ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0)); + ((hook.memoizedState = getServerSnapshot), (didReceiveUpdate = !0)); hook = hook.queue; updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [ subscribe @@ -3794,16 +3798,23 @@ function updateSyncExternalStore(subscribe, getSnapshot) { fiber.flags |= 2048; pushEffect( 9, - updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), + updateStoreInstance.bind( + null, + fiber, + hook, + getServerSnapshot, + getSnapshot + ), { destroy: void 0 }, null ); subscribe = workInProgressRoot; if (null === subscribe) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(subscribe, renderLanes$1) || - pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + isHydrating$jscomp$0 || + includesBlockingLane(subscribe, renderLanes$1) || + pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } - return nextSnapshot; + return getServerSnapshot; } function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) { fiber.flags |= 16384; @@ -16642,7 +16653,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1829 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-fbb135ff", + version: "18.3.0-www-classic-f5d45791", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2203 = { @@ -16672,7 +16683,7 @@ var internals$jscomp$inline_2203 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-fbb135ff" + reconcilerVersion: "18.3.0-www-classic-f5d45791" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2204 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -16915,4 +16926,4 @@ exports.unstable_renderSubtreeIntoContainer = function ( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-classic-fbb135ff"; +exports.version = "18.3.0-www-classic-f5d45791"; diff --git a/compiled/facebook-www/ReactDOM-prod.modern.js b/compiled/facebook-www/ReactDOM-prod.modern.js index c7c6221931441..4c7f1ccc281e3 100644 --- a/compiled/facebook-www/ReactDOM-prod.modern.js +++ b/compiled/facebook-www/ReactDOM-prod.modern.js @@ -3665,16 +3665,20 @@ function updateMutableSource(source, getSnapshot, subscribe) { var hook = updateWorkInProgressHook(); return useMutableSource(hook, source, getSnapshot, subscribe); } -function updateSyncExternalStore(subscribe, getSnapshot) { +function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { var fiber = currentlyRenderingFiber$1, hook = updateWorkInProgressHook(), - nextSnapshot = getSnapshot(), - snapshotChanged = !objectIs( - (currentHook || hook).memoizedState, - nextSnapshot - ); + isHydrating$jscomp$0 = isHydrating; + if (isHydrating$jscomp$0) { + if (void 0 === getServerSnapshot) throw Error(formatProdErrorMessage(407)); + getServerSnapshot = getServerSnapshot(); + } else getServerSnapshot = getSnapshot(); + var snapshotChanged = !objectIs( + (currentHook || hook).memoizedState, + getServerSnapshot + ); snapshotChanged && - ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0)); + ((hook.memoizedState = getServerSnapshot), (didReceiveUpdate = !0)); hook = hook.queue; updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [ subscribe @@ -3687,16 +3691,23 @@ function updateSyncExternalStore(subscribe, getSnapshot) { fiber.flags |= 2048; pushEffect( 9, - updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), + updateStoreInstance.bind( + null, + fiber, + hook, + getServerSnapshot, + getSnapshot + ), { destroy: void 0 }, null ); subscribe = workInProgressRoot; if (null === subscribe) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(subscribe, renderLanes$1) || - pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + isHydrating$jscomp$0 || + includesBlockingLane(subscribe, renderLanes$1) || + pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } - return nextSnapshot; + return getServerSnapshot; } function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) { fiber.flags |= 16384; @@ -16169,7 +16180,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1788 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-8a5299e6", + version: "18.3.0-www-modern-c54c7d5d", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2167 = { @@ -16200,7 +16211,7 @@ var internals$jscomp$inline_2167 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-8a5299e6" + reconcilerVersion: "18.3.0-www-modern-c54c7d5d" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2168 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -16371,4 +16382,4 @@ exports.unstable_createEventHandle = function (type, options) { return eventHandle; }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-modern-8a5299e6"; +exports.version = "18.3.0-www-modern-c54c7d5d"; diff --git a/compiled/facebook-www/ReactDOM-profiling.classic.js b/compiled/facebook-www/ReactDOM-profiling.classic.js index 3ec689da22aaf..b58ca9f9d8beb 100644 --- a/compiled/facebook-www/ReactDOM-profiling.classic.js +++ b/compiled/facebook-www/ReactDOM-profiling.classic.js @@ -3918,16 +3918,20 @@ function updateMutableSource(source, getSnapshot, subscribe) { var hook = updateWorkInProgressHook(); return useMutableSource(hook, source, getSnapshot, subscribe); } -function updateSyncExternalStore(subscribe, getSnapshot) { +function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { var fiber = currentlyRenderingFiber$1, hook = updateWorkInProgressHook(), - nextSnapshot = getSnapshot(), - snapshotChanged = !objectIs( - (currentHook || hook).memoizedState, - nextSnapshot - ); + isHydrating$jscomp$0 = isHydrating; + if (isHydrating$jscomp$0) { + if (void 0 === getServerSnapshot) throw Error(formatProdErrorMessage(407)); + getServerSnapshot = getServerSnapshot(); + } else getServerSnapshot = getSnapshot(); + var snapshotChanged = !objectIs( + (currentHook || hook).memoizedState, + getServerSnapshot + ); snapshotChanged && - ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0)); + ((hook.memoizedState = getServerSnapshot), (didReceiveUpdate = !0)); hook = hook.queue; updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [ subscribe @@ -3940,16 +3944,23 @@ function updateSyncExternalStore(subscribe, getSnapshot) { fiber.flags |= 2048; pushEffect( 9, - updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), + updateStoreInstance.bind( + null, + fiber, + hook, + getServerSnapshot, + getSnapshot + ), { destroy: void 0 }, null ); subscribe = workInProgressRoot; if (null === subscribe) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(subscribe, renderLanes$1) || - pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + isHydrating$jscomp$0 || + includesBlockingLane(subscribe, renderLanes$1) || + pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } - return nextSnapshot; + return getServerSnapshot; } function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) { fiber.flags |= 16384; @@ -17417,7 +17428,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1914 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-b9ad8cd3", + version: "18.3.0-www-classic-214289fa", rendererPackageName: "react-dom" }; (function (internals) { @@ -17461,7 +17472,7 @@ var devToolsConfig$jscomp$inline_1914 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-b9ad8cd3" + reconcilerVersion: "18.3.0-www-classic-214289fa" }); assign(Internals, { ReactBrowserEventEmitter: { @@ -17691,7 +17702,7 @@ exports.unstable_renderSubtreeIntoContainer = function ( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-classic-b9ad8cd3"; +exports.version = "18.3.0-www-classic-214289fa"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactDOM-profiling.modern.js b/compiled/facebook-www/ReactDOM-profiling.modern.js index f1a563c3cbb91..575130e638ff4 100644 --- a/compiled/facebook-www/ReactDOM-profiling.modern.js +++ b/compiled/facebook-www/ReactDOM-profiling.modern.js @@ -3811,16 +3811,20 @@ function updateMutableSource(source, getSnapshot, subscribe) { var hook = updateWorkInProgressHook(); return useMutableSource(hook, source, getSnapshot, subscribe); } -function updateSyncExternalStore(subscribe, getSnapshot) { +function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { var fiber = currentlyRenderingFiber$1, hook = updateWorkInProgressHook(), - nextSnapshot = getSnapshot(), - snapshotChanged = !objectIs( - (currentHook || hook).memoizedState, - nextSnapshot - ); + isHydrating$jscomp$0 = isHydrating; + if (isHydrating$jscomp$0) { + if (void 0 === getServerSnapshot) throw Error(formatProdErrorMessage(407)); + getServerSnapshot = getServerSnapshot(); + } else getServerSnapshot = getSnapshot(); + var snapshotChanged = !objectIs( + (currentHook || hook).memoizedState, + getServerSnapshot + ); snapshotChanged && - ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0)); + ((hook.memoizedState = getServerSnapshot), (didReceiveUpdate = !0)); hook = hook.queue; updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [ subscribe @@ -3833,16 +3837,23 @@ function updateSyncExternalStore(subscribe, getSnapshot) { fiber.flags |= 2048; pushEffect( 9, - updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), + updateStoreInstance.bind( + null, + fiber, + hook, + getServerSnapshot, + getSnapshot + ), { destroy: void 0 }, null ); subscribe = workInProgressRoot; if (null === subscribe) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(subscribe, renderLanes$1) || - pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + isHydrating$jscomp$0 || + includesBlockingLane(subscribe, renderLanes$1) || + pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } - return nextSnapshot; + return getServerSnapshot; } function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) { fiber.flags |= 16384; @@ -16938,7 +16949,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1873 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-a64d6dfb", + version: "18.3.0-www-modern-26883fc6", rendererPackageName: "react-dom" }; (function (internals) { @@ -16983,7 +16994,7 @@ var devToolsConfig$jscomp$inline_1873 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-a64d6dfb" + reconcilerVersion: "18.3.0-www-modern-26883fc6" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; exports.createPortal = function (children, container) { @@ -17141,7 +17152,7 @@ exports.unstable_createEventHandle = function (type, options) { return eventHandle; }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-modern-a64d6dfb"; +exports.version = "18.3.0-www-modern-26883fc6"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactDOMTesting-dev.classic.js b/compiled/facebook-www/ReactDOMTesting-dev.classic.js index ea9a467d72f5b..d83649e9f4df8 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.classic.js @@ -13933,8 +13933,6 @@ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // clean-up function, and we track the deps correctly, we can call pushEffect // directly, without storing any additional state. For the same reason, we // don't need to set a static flag, either. - // TODO: We can move this to the passive phase once we add a pre-commit - // consistency check. See the next comment. fiber.flags |= Passive$1; pushEffect( @@ -13952,18 +13950,33 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // normal rules of React, and only works because store updates are // always synchronous. - var nextSnapshot = getSnapshot(); + var nextSnapshot; + var isHydrating = getIsHydrating(); - { - if (!didWarnUncachedGetSnapshot) { - var cachedSnapshot = getSnapshot(); + if (isHydrating) { + // Needed for strict mode double render + if (getServerSnapshot === undefined) { + throw new Error( + "Missing getServerSnapshot, which is required for " + + "server-rendered content. Will revert to client rendering." + ); + } - if (!objectIs(nextSnapshot, cachedSnapshot)) { - error( - "The result of getSnapshot should be cached to avoid an infinite loop" - ); + nextSnapshot = getServerSnapshot(); + } else { + nextSnapshot = getSnapshot(); - didWarnUncachedGetSnapshot = true; + { + if (!didWarnUncachedGetSnapshot) { + var cachedSnapshot = getSnapshot(); + + if (!objectIs(nextSnapshot, cachedSnapshot)) { + error( + "The result of getSnapshot should be cached to avoid an infinite loop" + ); + + didWarnUncachedGetSnapshot = true; + } } } } @@ -13986,7 +13999,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { if ( inst.getSnapshot !== getSnapshot || - snapshotChanged || // Check if the susbcribe function changed. We can save some memory by + snapshotChanged || // Check if the subscribe function changed. We can save some memory by // checking whether we scheduled a subscription effect above. (workInProgressHook !== null && workInProgressHook.memoizedState.tag & HasEffect) @@ -14009,7 +14022,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { ); } - if (!includesBlockingLane(root, renderLanes$1)) { + if (!isHydrating && !includesBlockingLane(root, renderLanes$1)) { pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); } } @@ -14328,7 +14341,8 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var effect = hook.memoizedState; - var inst = effect.inst; // currentHook is null when rerendering after a render phase state update. + var inst = effect.inst; // currentHook is null on initial mount when rerendering after a render phase + // state update or for strict mode. if (currentHook !== null) { if (nextDeps !== null) { @@ -15577,7 +15591,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -15721,7 +15735,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -16052,7 +16066,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -16219,7 +16233,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -34785,7 +34799,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-cc8acd04"; +var ReactVersion = "18.3.0-www-classic-02013e9c"; function createPortal$1( children, diff --git a/compiled/facebook-www/ReactDOMTesting-dev.modern.js b/compiled/facebook-www/ReactDOMTesting-dev.modern.js index 9701448964500..5eb780184e4fb 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.modern.js @@ -13874,8 +13874,6 @@ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // clean-up function, and we track the deps correctly, we can call pushEffect // directly, without storing any additional state. For the same reason, we // don't need to set a static flag, either. - // TODO: We can move this to the passive phase once we add a pre-commit - // consistency check. See the next comment. fiber.flags |= Passive$1; pushEffect( @@ -13893,18 +13891,33 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // normal rules of React, and only works because store updates are // always synchronous. - var nextSnapshot = getSnapshot(); + var nextSnapshot; + var isHydrating = getIsHydrating(); - { - if (!didWarnUncachedGetSnapshot) { - var cachedSnapshot = getSnapshot(); + if (isHydrating) { + // Needed for strict mode double render + if (getServerSnapshot === undefined) { + throw new Error( + "Missing getServerSnapshot, which is required for " + + "server-rendered content. Will revert to client rendering." + ); + } - if (!objectIs(nextSnapshot, cachedSnapshot)) { - error( - "The result of getSnapshot should be cached to avoid an infinite loop" - ); + nextSnapshot = getServerSnapshot(); + } else { + nextSnapshot = getSnapshot(); - didWarnUncachedGetSnapshot = true; + { + if (!didWarnUncachedGetSnapshot) { + var cachedSnapshot = getSnapshot(); + + if (!objectIs(nextSnapshot, cachedSnapshot)) { + error( + "The result of getSnapshot should be cached to avoid an infinite loop" + ); + + didWarnUncachedGetSnapshot = true; + } } } } @@ -13927,7 +13940,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { if ( inst.getSnapshot !== getSnapshot || - snapshotChanged || // Check if the susbcribe function changed. We can save some memory by + snapshotChanged || // Check if the subscribe function changed. We can save some memory by // checking whether we scheduled a subscription effect above. (workInProgressHook !== null && workInProgressHook.memoizedState.tag & HasEffect) @@ -13950,7 +13963,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { ); } - if (!includesBlockingLane(root, renderLanes$1)) { + if (!isHydrating && !includesBlockingLane(root, renderLanes$1)) { pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); } } @@ -14269,7 +14282,8 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var effect = hook.memoizedState; - var inst = effect.inst; // currentHook is null when rerendering after a render phase state update. + var inst = effect.inst; // currentHook is null on initial mount when rerendering after a render phase + // state update or for strict mode. if (currentHook !== null) { if (nextDeps !== null) { @@ -15518,7 +15532,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -15662,7 +15676,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -15993,7 +16007,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -16160,7 +16174,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateSyncExternalStore(subscribe, getSnapshot); + return updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); }, useId: function () { currentHookNameInDev = "useId"; @@ -34630,7 +34644,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-b5e9f35e"; +var ReactVersion = "18.3.0-www-modern-350137bf"; function createPortal$1( children, diff --git a/compiled/facebook-www/ReactDOMTesting-prod.classic.js b/compiled/facebook-www/ReactDOMTesting-prod.classic.js index 0ed951552f1e5..6406b36378064 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.classic.js @@ -3858,16 +3858,20 @@ function updateMutableSource(source, getSnapshot, subscribe) { var hook = updateWorkInProgressHook(); return useMutableSource(hook, source, getSnapshot, subscribe); } -function updateSyncExternalStore(subscribe, getSnapshot) { +function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { var fiber = currentlyRenderingFiber$1, hook = updateWorkInProgressHook(), - nextSnapshot = getSnapshot(), - snapshotChanged = !objectIs( - (currentHook || hook).memoizedState, - nextSnapshot - ); + isHydrating$jscomp$0 = isHydrating; + if (isHydrating$jscomp$0) { + if (void 0 === getServerSnapshot) throw Error(formatProdErrorMessage(407)); + getServerSnapshot = getServerSnapshot(); + } else getServerSnapshot = getSnapshot(); + var snapshotChanged = !objectIs( + (currentHook || hook).memoizedState, + getServerSnapshot + ); snapshotChanged && - ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0)); + ((hook.memoizedState = getServerSnapshot), (didReceiveUpdate = !0)); hook = hook.queue; updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [ subscribe @@ -3880,16 +3884,23 @@ function updateSyncExternalStore(subscribe, getSnapshot) { fiber.flags |= 2048; pushEffect( 9, - updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), + updateStoreInstance.bind( + null, + fiber, + hook, + getServerSnapshot, + getSnapshot + ), { destroy: void 0 }, null ); subscribe = workInProgressRoot; if (null === subscribe) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(subscribe, renderLanes$1) || - pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + isHydrating$jscomp$0 || + includesBlockingLane(subscribe, renderLanes$1) || + pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } - return nextSnapshot; + return getServerSnapshot; } function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) { fiber.flags |= 16384; @@ -16971,7 +16982,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1858 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-e1e0fe51", + version: "18.3.0-www-classic-d297891e", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2237 = { @@ -17001,7 +17012,7 @@ var internals$jscomp$inline_2237 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-classic-e1e0fe51" + reconcilerVersion: "18.3.0-www-classic-d297891e" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2238 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -17395,4 +17406,4 @@ exports.unstable_renderSubtreeIntoContainer = function ( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-classic-e1e0fe51"; +exports.version = "18.3.0-www-classic-d297891e"; diff --git a/compiled/facebook-www/ReactDOMTesting-prod.modern.js b/compiled/facebook-www/ReactDOMTesting-prod.modern.js index dc61a5329dcc1..baf2ee0ef9aeb 100644 --- a/compiled/facebook-www/ReactDOMTesting-prod.modern.js +++ b/compiled/facebook-www/ReactDOMTesting-prod.modern.js @@ -3806,16 +3806,20 @@ function updateMutableSource(source, getSnapshot, subscribe) { var hook = updateWorkInProgressHook(); return useMutableSource(hook, source, getSnapshot, subscribe); } -function updateSyncExternalStore(subscribe, getSnapshot) { +function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { var fiber = currentlyRenderingFiber$1, hook = updateWorkInProgressHook(), - nextSnapshot = getSnapshot(), - snapshotChanged = !objectIs( - (currentHook || hook).memoizedState, - nextSnapshot - ); + isHydrating$jscomp$0 = isHydrating; + if (isHydrating$jscomp$0) { + if (void 0 === getServerSnapshot) throw Error(formatProdErrorMessage(407)); + getServerSnapshot = getServerSnapshot(); + } else getServerSnapshot = getSnapshot(); + var snapshotChanged = !objectIs( + (currentHook || hook).memoizedState, + getServerSnapshot + ); snapshotChanged && - ((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0)); + ((hook.memoizedState = getServerSnapshot), (didReceiveUpdate = !0)); hook = hook.queue; updateEffect(subscribeToStore.bind(null, fiber, hook, subscribe), [ subscribe @@ -3828,16 +3832,23 @@ function updateSyncExternalStore(subscribe, getSnapshot) { fiber.flags |= 2048; pushEffect( 9, - updateStoreInstance.bind(null, fiber, hook, nextSnapshot, getSnapshot), + updateStoreInstance.bind( + null, + fiber, + hook, + getServerSnapshot, + getSnapshot + ), { destroy: void 0 }, null ); subscribe = workInProgressRoot; if (null === subscribe) throw Error(formatProdErrorMessage(349)); - includesBlockingLane(subscribe, renderLanes$1) || - pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + isHydrating$jscomp$0 || + includesBlockingLane(subscribe, renderLanes$1) || + pushStoreConsistencyCheck(fiber, getSnapshot, getServerSnapshot); } - return nextSnapshot; + return getServerSnapshot; } function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) { fiber.flags |= 16384; @@ -16553,7 +16564,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1817 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-bc9d666a", + version: "18.3.0-www-modern-6995898a", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2201 = { @@ -16584,7 +16595,7 @@ var internals$jscomp$inline_2201 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-www-modern-bc9d666a" + reconcilerVersion: "18.3.0-www-modern-6995898a" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2202 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -16906,4 +16917,4 @@ exports.unstable_createEventHandle = function (type, options) { return eventHandle; }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-www-modern-bc9d666a"; +exports.version = "18.3.0-www-modern-6995898a"; diff --git a/compiled/facebook-www/ReactTestRenderer-dev.classic.js b/compiled/facebook-www/ReactTestRenderer-dev.classic.js index 28c2e53380152..b5d894b59bafe 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.classic.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.classic.js @@ -8050,8 +8050,6 @@ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // clean-up function, and we track the deps correctly, we can call pushEffect // directly, without storing any additional state. For the same reason, we // don't need to set a static flag, either. - // TODO: We can move this to the passive phase once we add a pre-commit - // consistency check. See the next comment. fiber.flags |= Passive$1; pushEffect( @@ -8069,18 +8067,22 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // normal rules of React, and only works because store updates are // always synchronous. - var nextSnapshot = getSnapshot(); + var nextSnapshot; { - if (!didWarnUncachedGetSnapshot) { - var cachedSnapshot = getSnapshot(); + nextSnapshot = getSnapshot(); - if (!objectIs(nextSnapshot, cachedSnapshot)) { - error( - "The result of getSnapshot should be cached to avoid an infinite loop" - ); + { + if (!didWarnUncachedGetSnapshot) { + var cachedSnapshot = getSnapshot(); - didWarnUncachedGetSnapshot = true; + if (!objectIs(nextSnapshot, cachedSnapshot)) { + error( + "The result of getSnapshot should be cached to avoid an infinite loop" + ); + + didWarnUncachedGetSnapshot = true; + } } } } @@ -8103,7 +8105,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { if ( inst.getSnapshot !== getSnapshot || - snapshotChanged || // Check if the susbcribe function changed. We can save some memory by + snapshotChanged || // Check if the subscribe function changed. We can save some memory by // checking whether we scheduled a subscription effect above. (workInProgressHook !== null && workInProgressHook.memoizedState.tag & HasEffect) @@ -8310,7 +8312,8 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var effect = hook.memoizedState; - var inst = effect.inst; // currentHook is null when rerendering after a render phase state update. + var inst = effect.inst; // currentHook is null on initial mount when rerendering after a render phase + // state update or for strict mode. if (currentHook !== null) { if (nextDeps !== null) { @@ -24549,7 +24552,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-b4adcaa5"; +var ReactVersion = "18.3.0-www-classic-2a7e99ed"; // Might add PROFILE later. diff --git a/compiled/facebook-www/ReactTestRenderer-dev.modern.js b/compiled/facebook-www/ReactTestRenderer-dev.modern.js index ba041bf14fa05..6860881435b5b 100644 --- a/compiled/facebook-www/ReactTestRenderer-dev.modern.js +++ b/compiled/facebook-www/ReactTestRenderer-dev.modern.js @@ -8050,8 +8050,6 @@ function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // clean-up function, and we track the deps correctly, we can call pushEffect // directly, without storing any additional state. For the same reason, we // don't need to set a static flag, either. - // TODO: We can move this to the passive phase once we add a pre-commit - // consistency check. See the next comment. fiber.flags |= Passive$1; pushEffect( @@ -8069,18 +8067,22 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { // normal rules of React, and only works because store updates are // always synchronous. - var nextSnapshot = getSnapshot(); + var nextSnapshot; { - if (!didWarnUncachedGetSnapshot) { - var cachedSnapshot = getSnapshot(); + nextSnapshot = getSnapshot(); - if (!objectIs(nextSnapshot, cachedSnapshot)) { - error( - "The result of getSnapshot should be cached to avoid an infinite loop" - ); + { + if (!didWarnUncachedGetSnapshot) { + var cachedSnapshot = getSnapshot(); - didWarnUncachedGetSnapshot = true; + if (!objectIs(nextSnapshot, cachedSnapshot)) { + error( + "The result of getSnapshot should be cached to avoid an infinite loop" + ); + + didWarnUncachedGetSnapshot = true; + } } } } @@ -8103,7 +8105,7 @@ function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { if ( inst.getSnapshot !== getSnapshot || - snapshotChanged || // Check if the susbcribe function changed. We can save some memory by + snapshotChanged || // Check if the subscribe function changed. We can save some memory by // checking whether we scheduled a subscription effect above. (workInProgressHook !== null && workInProgressHook.memoizedState.tag & HasEffect) @@ -8310,7 +8312,8 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { var hook = updateWorkInProgressHook(); var nextDeps = deps === undefined ? null : deps; var effect = hook.memoizedState; - var inst = effect.inst; // currentHook is null when rerendering after a render phase state update. + var inst = effect.inst; // currentHook is null on initial mount when rerendering after a render phase + // state update or for strict mode. if (currentHook !== null) { if (nextDeps !== null) { @@ -24549,7 +24552,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-bc9d666a"; +var ReactVersion = "18.3.0-www-modern-6995898a"; // Might add PROFILE later.