Skip to content

Commit

Permalink
Remove useMutableSource (#27011)
Browse files Browse the repository at this point in the history
## Summary

This PR cleans up `useMutableSource`. This has been blocked by a
remaining dependency internally at Meta, but that has now been deleted.

<!--
Explain the **motivation** for making this change. What existing problem
does the pull request solve?
-->

## How did you test this change?

```
yarn flow
yarn lint
yarn test --prod
```

<!--
Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes the user
interface.
How exactly did you verify that your PR solves the issue you wanted to
solve?
  If you leave this empty, your PR will very likely be closed.
-->

DiffTrain build for commit 80d9a40.
  • Loading branch information
noahlemen committed Jun 27, 2023
1 parent 8983ab3 commit 8afda46
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 1,481 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<78e16f0583c5e93e8b989135cc106bd4>>
* @generated SignedSource<<bfa37b9235cbe10193422349b5fb18a5>>
*/

'use strict';
Expand Down Expand Up @@ -1327,8 +1327,8 @@ function getNextLanes(root, wipLanes) {
// time it takes to show the final state, which is what they are actually
// waiting for.
//
// For those exceptions where entanglement is semantically important, like
// useMutableSource, we should ensure that there is no partial work at the
// For those exceptions where entanglement is semantically important,
// we should ensure that there is no partial work at the
// time we apply the entanglement.

var entangledLanes = root.entangledLanes;
Expand Down Expand Up @@ -1627,7 +1627,6 @@ function markRootFinished(root, remainingLanes) {
root.suspendedLanes = NoLanes;
root.pingedLanes = NoLanes;
root.expiredLanes &= remainingLanes;
root.mutableReadLanes &= remainingLanes;
root.entangledLanes &= remainingLanes;
root.errorRecoveryDisabledLanes &= remainingLanes;
var entanglements = root.entanglements;
Expand Down Expand Up @@ -5948,22 +5947,6 @@ var Passive =
/* */
8;

// and should be reset before starting a new render.
// This tracks which mutable sources need to be reset after a render.

var workInProgressSources = [];
function resetWorkInProgressVersions() {
for (var i = 0; i < workInProgressSources.length; i++) {
var mutableSource = workInProgressSources[i];

{
mutableSource._workInProgressVersionSecondary = null;
}
}

workInProgressSources.length = 0;
}

var ReactCurrentActQueue$2 = ReactSharedInternals.ReactCurrentActQueue; // A linked list of all the roots with pending work. In an idiomatic app,
// there's only a single root, but we do support multi root apps, hence this
// extra complexity. But this module is optimized for the single root case.
Expand Down Expand Up @@ -7441,18 +7424,6 @@ function rerenderReducer(reducer, initialArg, init) {
return [newState, dispatch];
}

function mountMutableSource(source, getSnapshot, subscribe) {
{
return undefined;
}
}

function updateMutableSource(source, getSnapshot, subscribe) {
{
return undefined;
}
}

function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
var fiber = currentlyRenderingFiber$1;
var hook = mountWorkInProgressHook();
Expand Down Expand Up @@ -8416,7 +8387,6 @@ var ContextOnlyDispatcher = {
useDebugValue: throwInvalidHookError,
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
useSyncExternalStore: throwInvalidHookError,
useId: throwInvalidHookError
};
Expand Down Expand Up @@ -8552,11 +8522,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountTransition();
},
useMutableSource: function (source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
mountHookTypesDev();
return mountMutableSource();
},
useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
mountHookTypesDev();
Expand Down Expand Up @@ -8671,11 +8636,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return mountTransition();
},
useMutableSource: function (source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
return mountMutableSource();
},
useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
Expand Down Expand Up @@ -8791,11 +8751,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateTransition();
},
useMutableSource: function (source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
return updateMutableSource();
},
useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
Expand Down Expand Up @@ -8910,11 +8865,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return rerenderTransition();
},
useMutableSource: function (source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
updateHookTypesDev();
return updateMutableSource();
},
useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
Expand Down Expand Up @@ -9047,12 +8997,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountTransition();
},
useMutableSource: function (source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
mountHookTypesDev();
return mountMutableSource();
},
useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
warnInvalidHookAccess();
Expand Down Expand Up @@ -9187,12 +9131,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateTransition();
},
useMutableSource: function (source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
updateHookTypesDev();
return updateMutableSource();
},
useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
warnInvalidHookAccess();
Expand Down Expand Up @@ -9327,12 +9265,6 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return rerenderTransition();
},
useMutableSource: function (source, getSnapshot, subscribe) {
currentHookNameInDev = "useMutableSource";
warnInvalidHookAccess();
updateHookTypesDev();
return updateMutableSource();
},
useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
warnInvalidHookAccess();
Expand Down Expand Up @@ -15410,7 +15342,6 @@ function completeWork(current, workInProgress, renderLanes) {
}
popHostContainer(workInProgress);
popTopLevelContextObject(workInProgress);
resetWorkInProgressVersions();

if (fiberRoot.pendingContext) {
fiberRoot.context = fiberRoot.pendingContext;
Expand Down Expand Up @@ -16059,7 +15990,6 @@ function unwindWork(current, workInProgress, renderLanes) {
}
popHostContainer(workInProgress);
popTopLevelContextObject(workInProgress);
resetWorkInProgressVersions();
var _flags = workInProgress.flags;

if (
Expand Down Expand Up @@ -16180,7 +16110,6 @@ function unwindInterruptedWork(current, interruptedWork, renderLanes) {
}
popHostContainer(interruptedWork);
popTopLevelContextObject(interruptedWork);
resetWorkInProgressVersions();
break;
}

Expand Down Expand Up @@ -23838,7 +23767,6 @@ function FiberRootNode(
this.suspendedLanes = NoLanes;
this.pingedLanes = NoLanes;
this.expiredLanes = NoLanes;
this.mutableReadLanes = NoLanes;
this.finishedLanes = NoLanes;
this.errorRecoveryDisabledLanes = NoLanes;
this.entangledLanes = NoLanes;
Expand Down Expand Up @@ -23929,7 +23857,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-canary-6aacd3fa1-20230626";
var ReactVersion = "18.3.0-canary-80d9a4011-20230627";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<77fc4f9a917cfed3650bc1553f28c0e2>>
* @generated SignedSource<<66065d19e6aa88d1eec3aaef75c93277>>
*/

"use strict";
Expand Down Expand Up @@ -477,7 +477,6 @@ function markRootFinished(root, remainingLanes) {
root.suspendedLanes = 0;
root.pingedLanes = 0;
root.expiredLanes &= remainingLanes;
root.mutableReadLanes &= remainingLanes;
root.entangledLanes &= remainingLanes;
root.errorRecoveryDisabledLanes &= remainingLanes;
remainingLanes = root.entanglements;
Expand Down Expand Up @@ -1955,12 +1954,6 @@ function findFirstSuspended(row) {
}
return null;
}
var workInProgressSources = [];
function resetWorkInProgressVersions() {
for (var i = 0; i < workInProgressSources.length; i++)
workInProgressSources[i]._workInProgressVersionSecondary = null;
workInProgressSources.length = 0;
}
var firstScheduledRoot = null,
lastScheduledRoot = null,
didScheduleMicrotask = !1,
Expand Down Expand Up @@ -2447,7 +2440,6 @@ function rerenderReducer(reducer) {
}
return [newState, dispatch];
}
function updateMutableSource() {}
function updateSyncExternalStore(subscribe, getSnapshot) {
var fiber = currentlyRenderingFiber$1,
hook = updateWorkInProgressHook();
Expand Down Expand Up @@ -2780,7 +2772,6 @@ var ContextOnlyDispatcher = {
useDebugValue: throwInvalidHookError,
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
useSyncExternalStore: throwInvalidHookError,
useId: throwInvalidHookError
};
Expand Down Expand Up @@ -2871,7 +2862,6 @@ var HooksDispatcherOnMount = {
mountWorkInProgressHook().memoizedState = stateHook;
return [!1, stateHook];
},
useMutableSource: function () {},
useSyncExternalStore: function (subscribe, getSnapshot) {
var fiber = currentlyRenderingFiber$1,
hook = mountWorkInProgressHook();
Expand Down Expand Up @@ -2943,7 +2933,6 @@ var HooksDispatcherOnMount = {
start
];
},
useMutableSource: updateMutableSource,
useSyncExternalStore: updateSyncExternalStore,
useId: updateId
};
Expand Down Expand Up @@ -2980,7 +2969,6 @@ var HooksDispatcherOnRerender = {
start
];
},
useMutableSource: updateMutableSource,
useSyncExternalStore: updateSyncExternalStore,
useId: updateId
};
Expand Down Expand Up @@ -4562,7 +4550,6 @@ function completeWork(current, workInProgress, renderLanes) {
popHostContainer(),
pop(didPerformWorkStackCursor),
pop(contextStackCursor$1),
resetWorkInProgressVersions(),
renderLanes.pendingContext &&
((renderLanes.context = renderLanes.pendingContext),
(renderLanes.pendingContext = null)),
Expand Down Expand Up @@ -4867,7 +4854,6 @@ function unwindWork(current, workInProgress) {
popHostContainer(),
pop(didPerformWorkStackCursor),
pop(contextStackCursor$1),
resetWorkInProgressVersions(),
(current = workInProgress.flags),
0 !== (current & 65536) && 0 === (current & 128)
? ((workInProgress.flags = (current & -65537) | 128), workInProgress)
Expand Down Expand Up @@ -4928,7 +4914,6 @@ function unwindInterruptedWork(current, interruptedWork) {
popHostContainer();
pop(didPerformWorkStackCursor);
pop(contextStackCursor$1);
resetWorkInProgressVersions();
break;
case 26:
case 27:
Expand Down Expand Up @@ -8200,7 +8185,6 @@ function FiberRootNode(
this.entangledLanes =
this.errorRecoveryDisabledLanes =
this.finishedLanes =
this.mutableReadLanes =
this.expiredLanes =
this.pingedLanes =
this.suspendedLanes =
Expand Down Expand Up @@ -8617,7 +8601,7 @@ var devToolsConfig$jscomp$inline_1031 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-6aacd3fa1-20230626",
version: "18.3.0-canary-80d9a4011-20230627",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1230 = {
Expand Down Expand Up @@ -8648,7 +8632,7 @@ var internals$jscomp$inline_1230 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-6aacd3fa1-20230626"
reconcilerVersion: "18.3.0-canary-80d9a4011-20230627"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1231 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Loading

0 comments on commit 8afda46

Please sign in to comment.