@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
6969 return self;
7070}
7171
72- var ReactVersion = "18.3.0-www-classic-8789cf1c ";
72+ var ReactVersion = "18.3.0-www-classic-bb3a0070 ";
7373
7474var LegacyRoot = 0;
7575var ConcurrentRoot = 1;
@@ -9802,7 +9802,7 @@ function updateDeferredValue(value, initialValue) {
98029802 var hook = updateWorkInProgressHook();
98039803 var resolvedCurrentHook = currentHook;
98049804 var prevValue = resolvedCurrentHook.memoizedState;
9805- return updateDeferredValueImpl(hook, prevValue, value);
9805+ return updateDeferredValueImpl(hook, prevValue, value, initialValue );
98069806}
98079807
98089808function rerenderDeferredValue(value, initialValue) {
@@ -9814,7 +9814,7 @@ function rerenderDeferredValue(value, initialValue) {
98149814 } else {
98159815 // This is a rerender during an update.
98169816 var prevValue = currentHook.memoizedState;
9817- return updateDeferredValueImpl(hook, prevValue, value);
9817+ return updateDeferredValueImpl(hook, prevValue, value, initialValue );
98189818 }
98199819}
98209820
@@ -9835,12 +9835,7 @@ function mountDeferredValueImpl(hook, value, initialValue) {
98359835 currentlyRenderingFiber$1.lanes,
98369836 deferredLane
98379837 );
9838- markSkippedUpdateLanes(deferredLane); // Set this to true to indicate that the rendered value is inconsistent
9839- // from the latest value. The name "baseState" doesn't really match how we
9840- // use it because we're reusing a state hook field instead of creating a
9841- // new one.
9842-
9843- hook.baseState = true;
9838+ markSkippedUpdateLanes(deferredLane);
98449839 return initialValue;
98459840 } else {
98469841 hook.memoizedState = value;
@@ -9849,46 +9844,49 @@ function mountDeferredValueImpl(hook, value, initialValue) {
98499844}
98509845
98519846function updateDeferredValueImpl(hook, prevValue, value, initialValue) {
9852- // TODO: We should also check if this component is going from
9853- // hidden -> visible. If so, it should use the initialValue arg.
9854- var shouldDeferValue = !includesOnlyNonUrgentLanes(renderLanes);
9855-
9856- if (shouldDeferValue) {
9857- // This is an urgent update. If the value has changed, keep using the
9858- // previous value and spawn a deferred render to update it later.
9859- if (!objectIs(value, prevValue)) {
9847+ if (objectIs(value, prevValue)) {
9848+ // The incoming value is referentially identical to the currently rendered
9849+ // value, so we can bail out quickly.
9850+ return value;
9851+ } else {
9852+ // Received a new value that's different from the current value.
9853+ // Check if we're inside a hidden tree
9854+ if (isCurrentTreeHidden()) {
9855+ // Revealing a prerendered tree is considered the same as mounting new
9856+ // one, so we reuse the "mount" path in this case.
9857+ var resultValue = mountDeferredValueImpl(hook, value, initialValue); // Unlike during an actual mount, we need to mark this as an update if
9858+ // the value changed.
9859+
9860+ if (!objectIs(resultValue, prevValue)) {
9861+ markWorkInProgressReceivedUpdate();
9862+ }
9863+
9864+ return resultValue;
9865+ }
9866+
9867+ var shouldDeferValue = !includesOnlyNonUrgentLanes(renderLanes);
9868+
9869+ if (shouldDeferValue) {
9870+ // This is an urgent update. Since the value has changed, keep using the
9871+ // previous value and spawn a deferred render to update it later.
98609872 // Schedule a deferred render
98619873 var deferredLane = requestDeferredLane();
98629874 currentlyRenderingFiber$1.lanes = mergeLanes(
98639875 currentlyRenderingFiber$1.lanes,
98649876 deferredLane
98659877 );
9866- markSkippedUpdateLanes(deferredLane); // Set this to true to indicate that the rendered value is inconsistent
9867- // from the latest value. The name "baseState" doesn't really match how we
9868- // use it because we're reusing a state hook field instead of creating a
9869- // new one.
9878+ markSkippedUpdateLanes(deferredLane); // Reuse the previous value. We do not need to mark this as an update,
9879+ // because we did not render a new value.
98709880
9871- hook.baseState = true;
9872- } // Reuse the previous value
9873-
9874- return prevValue;
9875- } else {
9876- // This is not an urgent update, so we can use the latest value regardless
9877- // of what it is. No need to defer it.
9878- // However, if we're currently inside a spawned render, then we need to mark
9879- // this as an update to prevent the fiber from bailing out.
9880- //
9881- // `baseState` is true when the current value is different from the rendered
9882- // value. The name doesn't really match how we use it because we're reusing
9883- // a state hook field instead of creating a new one.
9884- if (hook.baseState) {
9885- // Flip this back to false.
9886- hook.baseState = false;
9881+ return prevValue;
9882+ } else {
9883+ // This is not an urgent update, so we can use the latest value regardless
9884+ // of what it is. No need to defer it.
9885+ // Mark this as an update to prevent the fiber from bailing out.
98879886 markWorkInProgressReceivedUpdate();
9887+ hook.memoizedState = value;
9888+ return value;
98889889 }
9889-
9890- hook.memoizedState = value;
9891- return value;
98929890 }
98939891}
98949892
@@ -10825,7 +10823,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
1082510823 useDeferredValue: function (value, initialValue) {
1082610824 currentHookNameInDev = "useDeferredValue";
1082710825 updateHookTypesDev();
10828- return updateDeferredValue(value);
10826+ return updateDeferredValue(value, initialValue );
1082910827 },
1083010828 useTransition: function () {
1083110829 currentHookNameInDev = "useTransition";
@@ -11281,7 +11279,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
1128111279 currentHookNameInDev = "useDeferredValue";
1128211280 warnInvalidHookAccess();
1128311281 updateHookTypesDev();
11284- return updateDeferredValue(value);
11282+ return updateDeferredValue(value, initialValue );
1128511283 },
1128611284 useTransition: function () {
1128711285 currentHookNameInDev = "useTransition";
0 commit comments