React Native sync for revisions bd5bf55...95d762e

Summary:
This sync includes the following changes:
- **[95d762e40](https://github.com/facebook/react/commit/95d762e40 )**: Remove duplicate test //<Andrew Clark>//
- **[d4d1dc085](https://github.com/facebook/react/commit/d4d1dc085 )**: Reorder VARIANT feature flags ([#22266](https://github.com/facebook/react/pull/22266)) //<Dan Abramov>//
- **[2f156eafb](https://github.com/facebook/react/commit/2f156eafb )**: Adjust consoleManagedByDevToolsDuringStrictMode feature flag ([#22253](https://github.com/facebook/react/pull/22253)) //<Dan Abramov>//
- **[cfd819332](https://github.com/facebook/react/commit/cfd819332 )**: Add useSyncExternalStore to react-debug-tools ([#22240](https://github.com/facebook/react/pull/22240)) //<Andrew Clark>//
- **[8e80592a3](https://github.com/facebook/react/commit/8e80592a3 )**: Remove state queue from useSyncExternalStore ([#22265](https://github.com/facebook/react/pull/22265)) //<Andrew Clark>//
- **[06f98c168](https://github.com/facebook/react/commit/06f98c168 )**: Implement useSyncExternalStore in Fiber ([#22239](https://github.com/facebook/react/pull/22239)) //<Andrew Clark>//
- **[77912d9a0](https://github.com/facebook/react/commit/77912d9a0 )**: Wire up the native API for useSyncExternalStore ([#22237](https://github.com/facebook/react/pull/22237)) //<Andrew Clark>//
- **[031abd24b](https://github.com/facebook/react/commit/031abd24b )**: Add warning and test for useSyncExternalStore when getSnapshot isn't cached ([#22262](https://github.com/facebook/react/pull/22262)) //<salazarm>//
- **[b8884de24](https://github.com/facebook/react/commit/b8884de24 )**: break up import keyword to avoid being accidentally parsed as dynamic import statement in external code ([#21918](https://github.com/facebook/react/pull/21918)) //<Jianhua Zheng>//
- **[6d6bba5bf](https://github.com/facebook/react/commit/6d6bba5bf )**: Fix typo in ReactUpdatePriority-test.js ([#21958](https://github.com/facebook/react/pull/21958)) //<Ikko Ashimine>//
- **[0c0d1ddae](https://github.com/facebook/react/commit/0c0d1ddae )**: feat(eslint-plugin-react-hooks): support ESLint 8.x ([#22248](https://github.com/facebook/react/pull/22248)) //<Michaël De Boey>//
- **[1314299c7](https://github.com/facebook/react/commit/1314299c7 )**: Initial shim of useSyncExternalStore ([#22211](https://github.com/facebook/react/pull/22211)) //<Andrew Clark>//
- **[fc40f02ad](https://github.com/facebook/react/commit/fc40f02ad )**: Add consoleManagedByDevToolsDuringStrictMode feature flag in React Reconciler ([#22196](https://github.com/facebook/react/pull/22196)) //<Luna Ruan>//
- **[46a0f050a](https://github.com/facebook/react/commit/46a0f050a )**: Set up use-sync-external-store package ([#22202](https://github.com/facebook/react/pull/22202)) //<Andrew Clark>//
- **[8723e772b](https://github.com/facebook/react/commit/8723e772b )**: Fix a string interpolation typo in ReactHooks test ([#22174](https://github.com/facebook/react/pull/22174)) //<Matt Hargett>//
- **[60a30cf32](https://github.com/facebook/react/commit/60a30cf32 )**: Console Logging for StrictMode Double Rendering ([#22030](https://github.com/facebook/react/pull/22030)) //<Luna Ruan>//
- **[76bbad3e3](https://github.com/facebook/react/commit/76bbad3e3 )**: Add maxYieldMs feature flag in Scheduler ([#22165](https://github.com/facebook/react/pull/22165)) //<Ricky>//
- **[b0b53ae2c](https://github.com/facebook/react/commit/b0b53ae2c )**: Add feature flags for scheduler experiments ([#22105](https://github.com/facebook/react/pull/22105)) //<Ricky>//

Changelog:
[General][Changed] - React Native sync for revisions bd5bf55...95d762e

jest_e2e[run_all_tests]

Reviewed By: mdvacca

Differential Revision: D30809906

fbshipit-source-id: 131cfdf91e15f67fa59a5d925467e538ee89fe10
This commit is contained in:
Rick Hanlon 2021-09-10 12:16:17 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 0b3d28f8f1
Коммит 7f7f8188f2
7 изменённых файлов: 813 добавлений и 167 удалений

Просмотреть файл

@ -1 +1 @@
bd5bf555e1167e7088a4391e5cd419dccb39714c
95d762e406bd37c07693e3a5ddbd0f75289e8c3f

Просмотреть файл

@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<0105b67942f03415395650d296aa846a>>
* @generated SignedSource<<1a3cb2d94c0721509af63438d7639b77>>
*/
'use strict';
@ -32,32 +32,36 @@ var ReactSharedInternals =
function warn(format) {
{
for (
var _len = arguments.length,
args = new Array(_len > 1 ? _len - 1 : 0),
_key = 1;
_key < _len;
_key++
) {
args[_key - 1] = arguments[_key];
}
{
for (
var _len = arguments.length,
args = new Array(_len > 1 ? _len - 1 : 0),
_key = 1;
_key < _len;
_key++
) {
args[_key - 1] = arguments[_key];
}
printWarning("warn", format, args);
printWarning("warn", format, args);
}
}
}
function error(format) {
{
for (
var _len2 = arguments.length,
args = new Array(_len2 > 1 ? _len2 - 1 : 0),
_key2 = 1;
_key2 < _len2;
_key2++
) {
args[_key2 - 1] = arguments[_key2];
}
{
for (
var _len2 = arguments.length,
args = new Array(_len2 > 1 ? _len2 - 1 : 0),
_key2 = 1;
_key2 < _len2;
_key2++
) {
args[_key2 - 1] = arguments[_key2];
}
printWarning("error", format, args);
printWarning("error", format, args);
}
}
}
@ -5900,7 +5904,7 @@ function flushSyncCallbacks() {
return null;
}
var ReactVersion = "18.0.0-bd5bf555e-20210823";
var ReactVersion = "18.0.0-95d762e40-20210908";
var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
var NoTransition = 0;
@ -6978,12 +6982,12 @@ function getStateFromUpdate(
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
payload.call(instance, prevState, nextProps);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -7016,12 +7020,12 @@ function getStateFromUpdate(
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
_payload.call(instance, prevState, nextProps);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -7368,13 +7372,13 @@ function applyDerivedStateFromProps(
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
// Invoke the function an extra time to help detect side-effects.
partialState = getDerivedStateFromProps(nextProps, prevState);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -7486,7 +7490,7 @@ function checkShouldComponentUpdate(
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
// Invoke the function an extra time to help detect side-effects.
@ -7496,7 +7500,7 @@ function checkShouldComponentUpdate(
nextContext
);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -7820,12 +7824,12 @@ function constructClassInstance(workInProgress, ctor, props) {
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
instance = new ctor(props, context); // eslint-disable-line no-new
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
}
@ -9973,6 +9977,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
var didWarnAboutMismatchedHooksForComponent;
var didWarnAboutUseOpaqueIdentifier;
var didWarnUncachedGetSnapshot;
{
didWarnAboutUseOpaqueIdentifier = {};
@ -10448,14 +10453,15 @@ function mountReducer(reducer, initialArg, init) {
}
hook.memoizedState = hook.baseState = initialState;
var queue = (hook.queue = {
var queue = {
pending: null,
interleaved: null,
lanes: NoLanes,
dispatch: null,
lastRenderedReducer: reducer,
lastRenderedState: initialState
});
};
hook.queue = queue;
var dispatch = (queue.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -10752,9 +10758,9 @@ function readFromUnsubscribedMutableSource(root, source, getSnapshot) {
{
// eslint-disable-next-line react-internal/no-production-logging
if (console.log.__reactDisabledLog) {
// If the logs are disabled, this is the dev-only double render. This is
// only reachable if there was a mutation during render. Show a helpful
if (getIsStrictModeForDevtools()) {
// If getIsStrictModeForDevtools is true, this is the dev-only double render
// This is only reachable if there was a mutation during render. Show a helpful
// error message.
//
// Something interesting to note: because we only double render in
@ -10955,6 +10961,135 @@ function updateMutableSource(source, getSnapshot, subscribe) {
return useMutableSource(hook, source, getSnapshot, subscribe);
}
function mountSyncExternalStore(subscribe, getSnapshot) {
var hook = mountWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the
// normal rules of React, and only works because store updates are
// always synchronous.
var nextSnapshot = getSnapshot();
{
if (!didWarnUncachedGetSnapshot) {
if (nextSnapshot !== getSnapshot()) {
error(
"The result of getSnapshot should be cached to avoid an infinite loop"
);
didWarnUncachedGetSnapshot = true;
}
}
}
hook.memoizedState = nextSnapshot;
var inst = {
value: nextSnapshot,
getSnapshot: getSnapshot
};
hook.queue = inst;
return useSyncExternalStore(hook, inst, subscribe, getSnapshot, nextSnapshot);
}
function updateSyncExternalStore(subscribe, getSnapshot) {
var hook = updateWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the
// normal rules of React, and only works because store updates are
// always synchronous.
var nextSnapshot = getSnapshot();
{
if (!didWarnUncachedGetSnapshot) {
if (nextSnapshot !== getSnapshot()) {
error(
"The result of getSnapshot should be cached to avoid an infinite loop"
);
didWarnUncachedGetSnapshot = true;
}
}
}
var prevSnapshot = hook.memoizedState;
if (!objectIs(prevSnapshot, nextSnapshot)) {
hook.memoizedState = nextSnapshot;
markWorkInProgressReceivedUpdate();
}
var inst = hook.queue;
return useSyncExternalStore(hook, inst, subscribe, getSnapshot, nextSnapshot);
}
function useSyncExternalStore(
hook,
inst,
subscribe,
getSnapshot,
nextSnapshot
) {
var fiber = currentlyRenderingFiber$1;
var dispatcher = ReactCurrentDispatcher$1.current; // Track the latest getSnapshot function with a ref. This needs to be updated
// in the layout phase so we can access it during the tearing check that
// happens on subscribe.
// TODO: Circumvent SSR warning
dispatcher.useLayoutEffect(
function() {
inst.value = nextSnapshot;
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
// commit phase if there was an interleaved mutation. In concurrent mode
// this can happen all the time, but even in synchronous mode, an earlier
// effect may have mutated the store.
// TODO: Move the tearing checks to an earlier, pre-commit phase so that the
// layout effects always observe a consistent tree.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceStoreRerender(fiber);
}
},
[subscribe, nextSnapshot, getSnapshot]
);
dispatcher.useEffect(
function() {
var handleStoreChange = function() {
// TODO: Because there is no cross-renderer API for batching updates, it's
// up to the consumer of this library to wrap their subscription event
// with unstable_batchedUpdates. Should we try to detect when this isn't
// the case and print a warning in development?
// The store changed. Check if the snapshot changed since the last time we
// read from the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceStoreRerender(fiber);
}
}; // Check for changes right before subscribing. Subsequent changes will be
// detected in the subscription handler.
handleStoreChange(); // Subscribe to the store and return a clean-up function.
return subscribe(handleStoreChange);
},
[subscribe]
);
return nextSnapshot;
}
function checkIfSnapshotChanged(inst) {
var latestGetSnapshot = inst.getSnapshot;
var prevValue = inst.value;
try {
var nextValue = latestGetSnapshot();
return !objectIs(prevValue, nextValue);
} catch (error) {
return true;
}
}
function forceStoreRerender(fiber) {
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
@ -10964,14 +11099,15 @@ function mountState(initialState) {
}
hook.memoizedState = hook.baseState = initialState;
var queue = (hook.queue = {
var queue = {
pending: null,
interleaved: null,
lanes: NoLanes,
dispatch: null,
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
});
};
hook.queue = queue;
var dispatch = (queue.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -11559,6 +11695,7 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
useSyncExternalStore: throwInvalidHookError,
useOpaqueIdentifier: throwInvalidHookError,
unstable_isNewReconciler: enableNewReconciler
};
@ -11685,6 +11822,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
mountHookTypesDev();
return mountSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
mountHookTypesDev();
@ -11783,6 +11925,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return mountMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
return mountSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
updateHookTypesDev();
@ -11881,6 +12028,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
return updateSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
updateHookTypesDev();
@ -11979,6 +12131,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
return updateSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
updateHookTypesDev();
@ -12091,6 +12248,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
warnInvalidHookAccess();
mountHookTypesDev();
return mountSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
warnInvalidHookAccess();
@ -12204,6 +12367,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
warnInvalidHookAccess();
updateHookTypesDev();
return updateSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
warnInvalidHookAccess();
@ -12317,6 +12486,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
warnInvalidHookAccess();
updateHookTypesDev();
return updateSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
warnInvalidHookAccess();
@ -14178,7 +14353,7 @@ function updateForwardRef(
);
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
nextChildren = renderWithHooks(
@ -14190,7 +14365,7 @@ function updateForwardRef(
renderLanes
);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -14648,7 +14823,7 @@ function updateFunctionComponent(
);
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
nextChildren = renderWithHooks(
@ -14660,7 +14835,7 @@ function updateFunctionComponent(
renderLanes
);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -14858,12 +15033,12 @@ function finishClassComponent(
nextChildren = instance.render();
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
instance.render();
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -15327,7 +15502,7 @@ function mountIndeterminateComponent(
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
value = renderWithHooks(
@ -15339,7 +15514,7 @@ function mountIndeterminateComponent(
renderLanes
);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
}
@ -22371,6 +22546,7 @@ var shouldSuspendImpl = function(fiber) {
function shouldSuspend(fiber) {
return shouldSuspendImpl(fiber);
}
var isStrictMode = false;
var overrideHookState = null;
var overrideHookStateDeletePath = null;
var overrideHookStateRenamePath = null;
@ -22593,6 +22769,20 @@ function getCurrentFiberForDevTools() {
return current;
}
function getIsStrictModeForDevtools() {
return isStrictMode;
}
function setIsStrictModeForDevtools(newIsStrictMode) {
isStrictMode = newIsStrictMode;
{
if (newIsStrictMode) {
disableLogs();
} else {
reenableLogs();
}
}
}
function injectIntoDevTools(devToolsConfig) {
var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
@ -22621,6 +22811,7 @@ function injectIntoDevTools(devToolsConfig) {
setRefreshHandler: setRefreshHandler,
// Enables DevTools to append owner stacks to error messages in DEV mode.
getCurrentFiber: getCurrentFiberForDevTools,
getIsStrictMode: getIsStrictModeForDevtools,
// Enables DevTools to detect reconciler version rather than renderer version
// which may not match for third party renderers.
reconcilerVersion: ReactVersion

Просмотреть файл

@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<64b88a48c0e9e26ebfbee2286b912b78>>
* @generated SignedSource<<6fd8e2fc263f451cb6e073eae96b19f3>>
*/
"use strict";
@ -3632,11 +3632,58 @@ function updateMutableSource(source, getSnapshot, subscribe) {
var hook = updateWorkInProgressHook();
return useMutableSource(hook, source, getSnapshot, subscribe);
}
function mountSyncExternalStore(subscribe, getSnapshot) {
var hook = mountWorkInProgressHook(),
nextSnapshot = getSnapshot();
hook.memoizedState = nextSnapshot;
var inst = { value: nextSnapshot, getSnapshot: getSnapshot };
hook.queue = inst;
return useSyncExternalStore(hook, inst, subscribe, getSnapshot, nextSnapshot);
}
function useSyncExternalStore(
hook,
inst,
subscribe,
getSnapshot,
nextSnapshot
) {
var fiber = currentlyRenderingFiber$1;
hook = ReactCurrentDispatcher$1.current;
hook.useLayoutEffect(
function() {
inst.value = nextSnapshot;
inst.getSnapshot = getSnapshot;
checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
},
[subscribe, nextSnapshot, getSnapshot]
);
hook.useEffect(
function() {
function handleStoreChange() {
checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
}
handleStoreChange();
return subscribe(handleStoreChange);
},
[subscribe]
);
return nextSnapshot;
}
function checkIfSnapshotChanged(inst) {
var latestGetSnapshot = inst.getSnapshot;
inst = inst.value;
try {
var nextValue = latestGetSnapshot();
return !objectIs(inst, nextValue);
} catch (error) {
return !0;
}
}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
hook.memoizedState = hook.baseState = initialState;
initialState = hook.queue = {
initialState = {
pending: null,
interleaved: null,
lanes: 0,
@ -3644,6 +3691,7 @@ function mountState(initialState) {
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
};
hook.queue = initialState;
initialState = initialState.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -3853,6 +3901,7 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
useSyncExternalStore: throwInvalidHookError,
useOpaqueIdentifier: throwInvalidHookError,
unstable_isNewReconciler: !1
},
@ -3890,7 +3939,7 @@ var ContextOnlyDispatcher = {
var hook = mountWorkInProgressHook();
initialArg = void 0 !== init ? init(initialArg) : initialArg;
hook.memoizedState = hook.baseState = initialArg;
reducer = hook.queue = {
reducer = {
pending: null,
interleaved: null,
lanes: 0,
@ -3898,6 +3947,7 @@ var ContextOnlyDispatcher = {
lastRenderedReducer: reducer,
lastRenderedState: initialArg
};
hook.queue = reducer;
reducer = reducer.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -3946,6 +3996,7 @@ var ContextOnlyDispatcher = {
};
return useMutableSource(hook, source, getSnapshot, subscribe);
},
useSyncExternalStore: mountSyncExternalStore,
useOpaqueIdentifier: function() {
throw Error("Not yet implemented");
},
@ -3989,6 +4040,19 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
useSyncExternalStore: function(subscribe, getSnapshot) {
var hook = updateWorkInProgressHook(),
nextSnapshot = getSnapshot();
objectIs(hook.memoizedState, nextSnapshot) ||
((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0));
return useSyncExternalStore(
hook,
hook.queue,
subscribe,
getSnapshot,
nextSnapshot
);
},
useOpaqueIdentifier: function() {
return updateReducer(basicStateReducer)[0];
},
@ -4032,6 +4096,7 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
useSyncExternalStore: mountSyncExternalStore,
useOpaqueIdentifier: function() {
return rerenderReducer(basicStateReducer)[0];
},
@ -7930,10 +7995,10 @@ batchedUpdatesImpl = function(fn, a) {
}
};
var roots = new Map(),
devToolsConfig$jscomp$inline_948 = {
devToolsConfig$jscomp$inline_953 = {
findFiberByHostInstance: getInstanceFromInstance,
bundleType: 0,
version: "18.0.0-bd5bf555e-20210823",
version: "18.0.0-95d762e40-20210908",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function() {
@ -7948,11 +8013,11 @@ var roots = new Map(),
}.bind(null, findNodeHandle)
}
};
var internals$jscomp$inline_1189 = {
bundleType: devToolsConfig$jscomp$inline_948.bundleType,
version: devToolsConfig$jscomp$inline_948.version,
rendererPackageName: devToolsConfig$jscomp$inline_948.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_948.rendererConfig,
var internals$jscomp$inline_1194 = {
bundleType: devToolsConfig$jscomp$inline_953.bundleType,
version: devToolsConfig$jscomp$inline_953.version,
rendererPackageName: devToolsConfig$jscomp$inline_953.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_953.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
@ -7968,26 +8033,27 @@ var internals$jscomp$inline_1189 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
devToolsConfig$jscomp$inline_948.findFiberByHostInstance ||
devToolsConfig$jscomp$inline_953.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.0.0-bd5bf555e-20210823"
getIsStrictMode: null,
reconcilerVersion: "18.0.0-95d762e40-20210908"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1190 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
var hook$jscomp$inline_1195 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
!hook$jscomp$inline_1190.isDisabled &&
hook$jscomp$inline_1190.supportsFiber
!hook$jscomp$inline_1195.isDisabled &&
hook$jscomp$inline_1195.supportsFiber
)
try {
(rendererID = hook$jscomp$inline_1190.inject(
internals$jscomp$inline_1189
(rendererID = hook$jscomp$inline_1195.inject(
internals$jscomp$inline_1194
)),
(injectedHook = hook$jscomp$inline_1190);
(injectedHook = hook$jscomp$inline_1195);
} catch (err) {}
}
exports.createPortal = function(children, containerTag) {

Просмотреть файл

@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<f021bce2048d654b3e2e31276c91433c>>
* @generated SignedSource<<a71955225824e1ab165c975361c725ed>>
*/
"use strict";
@ -3680,11 +3680,58 @@ function updateMutableSource(source, getSnapshot, subscribe) {
var hook = updateWorkInProgressHook();
return useMutableSource(hook, source, getSnapshot, subscribe);
}
function mountSyncExternalStore(subscribe, getSnapshot) {
var hook = mountWorkInProgressHook(),
nextSnapshot = getSnapshot();
hook.memoizedState = nextSnapshot;
var inst = { value: nextSnapshot, getSnapshot: getSnapshot };
hook.queue = inst;
return useSyncExternalStore(hook, inst, subscribe, getSnapshot, nextSnapshot);
}
function useSyncExternalStore(
hook,
inst,
subscribe,
getSnapshot,
nextSnapshot
) {
var fiber = currentlyRenderingFiber$1;
hook = ReactCurrentDispatcher$1.current;
hook.useLayoutEffect(
function() {
inst.value = nextSnapshot;
inst.getSnapshot = getSnapshot;
checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
},
[subscribe, nextSnapshot, getSnapshot]
);
hook.useEffect(
function() {
function handleStoreChange() {
checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
}
handleStoreChange();
return subscribe(handleStoreChange);
},
[subscribe]
);
return nextSnapshot;
}
function checkIfSnapshotChanged(inst) {
var latestGetSnapshot = inst.getSnapshot;
inst = inst.value;
try {
var nextValue = latestGetSnapshot();
return !objectIs(inst, nextValue);
} catch (error) {
return !0;
}
}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
hook.memoizedState = hook.baseState = initialState;
initialState = hook.queue = {
initialState = {
pending: null,
interleaved: null,
lanes: 0,
@ -3692,6 +3739,7 @@ function mountState(initialState) {
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
};
hook.queue = initialState;
initialState = initialState.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -3901,6 +3949,7 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
useSyncExternalStore: throwInvalidHookError,
useOpaqueIdentifier: throwInvalidHookError,
unstable_isNewReconciler: !1
},
@ -3938,7 +3987,7 @@ var ContextOnlyDispatcher = {
var hook = mountWorkInProgressHook();
initialArg = void 0 !== init ? init(initialArg) : initialArg;
hook.memoizedState = hook.baseState = initialArg;
reducer = hook.queue = {
reducer = {
pending: null,
interleaved: null,
lanes: 0,
@ -3946,6 +3995,7 @@ var ContextOnlyDispatcher = {
lastRenderedReducer: reducer,
lastRenderedState: initialArg
};
hook.queue = reducer;
reducer = reducer.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -3994,6 +4044,7 @@ var ContextOnlyDispatcher = {
};
return useMutableSource(hook, source, getSnapshot, subscribe);
},
useSyncExternalStore: mountSyncExternalStore,
useOpaqueIdentifier: function() {
throw Error("Not yet implemented");
},
@ -4037,6 +4088,19 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
useSyncExternalStore: function(subscribe, getSnapshot) {
var hook = updateWorkInProgressHook(),
nextSnapshot = getSnapshot();
objectIs(hook.memoizedState, nextSnapshot) ||
((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0));
return useSyncExternalStore(
hook,
hook.queue,
subscribe,
getSnapshot,
nextSnapshot
);
},
useOpaqueIdentifier: function() {
return updateReducer(basicStateReducer)[0];
},
@ -4080,6 +4144,7 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
useSyncExternalStore: mountSyncExternalStore,
useOpaqueIdentifier: function() {
return rerenderReducer(basicStateReducer)[0];
},
@ -8375,10 +8440,10 @@ batchedUpdatesImpl = function(fn, a) {
}
};
var roots = new Map(),
devToolsConfig$jscomp$inline_978 = {
devToolsConfig$jscomp$inline_983 = {
findFiberByHostInstance: getInstanceFromInstance,
bundleType: 0,
version: "18.0.0-bd5bf555e-20210823",
version: "18.0.0-95d762e40-20210908",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function() {
@ -8393,11 +8458,11 @@ var roots = new Map(),
}.bind(null, findNodeHandle)
}
};
var internals$jscomp$inline_1239 = {
bundleType: devToolsConfig$jscomp$inline_978.bundleType,
version: devToolsConfig$jscomp$inline_978.version,
rendererPackageName: devToolsConfig$jscomp$inline_978.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_978.rendererConfig,
var internals$jscomp$inline_1244 = {
bundleType: devToolsConfig$jscomp$inline_983.bundleType,
version: devToolsConfig$jscomp$inline_983.version,
rendererPackageName: devToolsConfig$jscomp$inline_983.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_983.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
@ -8413,26 +8478,27 @@ var internals$jscomp$inline_1239 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
devToolsConfig$jscomp$inline_978.findFiberByHostInstance ||
devToolsConfig$jscomp$inline_983.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.0.0-bd5bf555e-20210823"
getIsStrictMode: null,
reconcilerVersion: "18.0.0-95d762e40-20210908"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1240 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
var hook$jscomp$inline_1245 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
!hook$jscomp$inline_1240.isDisabled &&
hook$jscomp$inline_1240.supportsFiber
!hook$jscomp$inline_1245.isDisabled &&
hook$jscomp$inline_1245.supportsFiber
)
try {
(rendererID = hook$jscomp$inline_1240.inject(
internals$jscomp$inline_1239
(rendererID = hook$jscomp$inline_1245.inject(
internals$jscomp$inline_1244
)),
(injectedHook = hook$jscomp$inline_1240);
(injectedHook = hook$jscomp$inline_1245);
} catch (err) {}
}
exports.createPortal = function(children, containerTag) {

Просмотреть файл

@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<121565373640523240f808b242fb487f>>
* @generated SignedSource<<0aa534c810fde3c5289b4c849e474d9e>>
*/
'use strict';
@ -32,32 +32,36 @@ var ReactSharedInternals =
function warn(format) {
{
for (
var _len = arguments.length,
args = new Array(_len > 1 ? _len - 1 : 0),
_key = 1;
_key < _len;
_key++
) {
args[_key - 1] = arguments[_key];
}
{
for (
var _len = arguments.length,
args = new Array(_len > 1 ? _len - 1 : 0),
_key = 1;
_key < _len;
_key++
) {
args[_key - 1] = arguments[_key];
}
printWarning("warn", format, args);
printWarning("warn", format, args);
}
}
}
function error(format) {
{
for (
var _len2 = arguments.length,
args = new Array(_len2 > 1 ? _len2 - 1 : 0),
_key2 = 1;
_key2 < _len2;
_key2++
) {
args[_key2 - 1] = arguments[_key2];
}
{
for (
var _len2 = arguments.length,
args = new Array(_len2 > 1 ? _len2 - 1 : 0),
_key2 = 1;
_key2 < _len2;
_key2++
) {
args[_key2 - 1] = arguments[_key2];
}
printWarning("error", format, args);
printWarning("error", format, args);
}
}
}
@ -6134,7 +6138,7 @@ function flushSyncCallbacks() {
return null;
}
var ReactVersion = "18.0.0-bd5bf555e-20210823";
var ReactVersion = "18.0.0-95d762e40-20210908";
var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
var NoTransition = 0;
@ -7212,12 +7216,12 @@ function getStateFromUpdate(
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
payload.call(instance, prevState, nextProps);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -7250,12 +7254,12 @@ function getStateFromUpdate(
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
_payload.call(instance, prevState, nextProps);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -7602,13 +7606,13 @@ function applyDerivedStateFromProps(
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
// Invoke the function an extra time to help detect side-effects.
partialState = getDerivedStateFromProps(nextProps, prevState);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -7720,7 +7724,7 @@ function checkShouldComponentUpdate(
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
// Invoke the function an extra time to help detect side-effects.
@ -7730,7 +7734,7 @@ function checkShouldComponentUpdate(
nextContext
);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -8054,12 +8058,12 @@ function constructClassInstance(workInProgress, ctor, props) {
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
instance = new ctor(props, context); // eslint-disable-line no-new
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
}
@ -10207,6 +10211,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher,
ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
var didWarnAboutMismatchedHooksForComponent;
var didWarnAboutUseOpaqueIdentifier;
var didWarnUncachedGetSnapshot;
{
didWarnAboutUseOpaqueIdentifier = {};
@ -10682,14 +10687,15 @@ function mountReducer(reducer, initialArg, init) {
}
hook.memoizedState = hook.baseState = initialState;
var queue = (hook.queue = {
var queue = {
pending: null,
interleaved: null,
lanes: NoLanes,
dispatch: null,
lastRenderedReducer: reducer,
lastRenderedState: initialState
});
};
hook.queue = queue;
var dispatch = (queue.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -10986,9 +10992,9 @@ function readFromUnsubscribedMutableSource(root, source, getSnapshot) {
{
// eslint-disable-next-line react-internal/no-production-logging
if (console.log.__reactDisabledLog) {
// If the logs are disabled, this is the dev-only double render. This is
// only reachable if there was a mutation during render. Show a helpful
if (getIsStrictModeForDevtools()) {
// If getIsStrictModeForDevtools is true, this is the dev-only double render
// This is only reachable if there was a mutation during render. Show a helpful
// error message.
//
// Something interesting to note: because we only double render in
@ -11189,6 +11195,135 @@ function updateMutableSource(source, getSnapshot, subscribe) {
return useMutableSource(hook, source, getSnapshot, subscribe);
}
function mountSyncExternalStore(subscribe, getSnapshot) {
var hook = mountWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the
// normal rules of React, and only works because store updates are
// always synchronous.
var nextSnapshot = getSnapshot();
{
if (!didWarnUncachedGetSnapshot) {
if (nextSnapshot !== getSnapshot()) {
error(
"The result of getSnapshot should be cached to avoid an infinite loop"
);
didWarnUncachedGetSnapshot = true;
}
}
}
hook.memoizedState = nextSnapshot;
var inst = {
value: nextSnapshot,
getSnapshot: getSnapshot
};
hook.queue = inst;
return useSyncExternalStore(hook, inst, subscribe, getSnapshot, nextSnapshot);
}
function updateSyncExternalStore(subscribe, getSnapshot) {
var hook = updateWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the
// normal rules of React, and only works because store updates are
// always synchronous.
var nextSnapshot = getSnapshot();
{
if (!didWarnUncachedGetSnapshot) {
if (nextSnapshot !== getSnapshot()) {
error(
"The result of getSnapshot should be cached to avoid an infinite loop"
);
didWarnUncachedGetSnapshot = true;
}
}
}
var prevSnapshot = hook.memoizedState;
if (!objectIs(prevSnapshot, nextSnapshot)) {
hook.memoizedState = nextSnapshot;
markWorkInProgressReceivedUpdate();
}
var inst = hook.queue;
return useSyncExternalStore(hook, inst, subscribe, getSnapshot, nextSnapshot);
}
function useSyncExternalStore(
hook,
inst,
subscribe,
getSnapshot,
nextSnapshot
) {
var fiber = currentlyRenderingFiber$1;
var dispatcher = ReactCurrentDispatcher$1.current; // Track the latest getSnapshot function with a ref. This needs to be updated
// in the layout phase so we can access it during the tearing check that
// happens on subscribe.
// TODO: Circumvent SSR warning
dispatcher.useLayoutEffect(
function() {
inst.value = nextSnapshot;
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
// commit phase if there was an interleaved mutation. In concurrent mode
// this can happen all the time, but even in synchronous mode, an earlier
// effect may have mutated the store.
// TODO: Move the tearing checks to an earlier, pre-commit phase so that the
// layout effects always observe a consistent tree.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceStoreRerender(fiber);
}
},
[subscribe, nextSnapshot, getSnapshot]
);
dispatcher.useEffect(
function() {
var handleStoreChange = function() {
// TODO: Because there is no cross-renderer API for batching updates, it's
// up to the consumer of this library to wrap their subscription event
// with unstable_batchedUpdates. Should we try to detect when this isn't
// the case and print a warning in development?
// The store changed. Check if the snapshot changed since the last time we
// read from the store.
if (checkIfSnapshotChanged(inst)) {
// Force a re-render.
forceStoreRerender(fiber);
}
}; // Check for changes right before subscribing. Subsequent changes will be
// detected in the subscription handler.
handleStoreChange(); // Subscribe to the store and return a clean-up function.
return subscribe(handleStoreChange);
},
[subscribe]
);
return nextSnapshot;
}
function checkIfSnapshotChanged(inst) {
var latestGetSnapshot = inst.getSnapshot;
var prevValue = inst.value;
try {
var nextValue = latestGetSnapshot();
return !objectIs(prevValue, nextValue);
} catch (error) {
return true;
}
}
function forceStoreRerender(fiber) {
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
@ -11198,14 +11333,15 @@ function mountState(initialState) {
}
hook.memoizedState = hook.baseState = initialState;
var queue = (hook.queue = {
var queue = {
pending: null,
interleaved: null,
lanes: NoLanes,
dispatch: null,
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
});
};
hook.queue = queue;
var dispatch = (queue.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -11814,6 +11950,7 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
useSyncExternalStore: throwInvalidHookError,
useOpaqueIdentifier: throwInvalidHookError,
unstable_isNewReconciler: enableNewReconciler
};
@ -11940,6 +12077,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
mountHookTypesDev();
return mountSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
mountHookTypesDev();
@ -12038,6 +12180,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return mountMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
return mountSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
updateHookTypesDev();
@ -12136,6 +12283,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
return updateSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
updateHookTypesDev();
@ -12234,6 +12386,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
updateHookTypesDev();
return updateSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
updateHookTypesDev();
@ -12346,6 +12503,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
mountHookTypesDev();
return mountMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
warnInvalidHookAccess();
mountHookTypesDev();
return mountSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
warnInvalidHookAccess();
@ -12459,6 +12622,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
warnInvalidHookAccess();
updateHookTypesDev();
return updateSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
warnInvalidHookAccess();
@ -12572,6 +12741,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
updateHookTypesDev();
return updateMutableSource(source, getSnapshot, subscribe);
},
useSyncExternalStore: function(subscribe, getSnapshot) {
currentHookNameInDev = "useSyncExternalStore";
warnInvalidHookAccess();
updateHookTypesDev();
return updateSyncExternalStore(subscribe, getSnapshot);
},
useOpaqueIdentifier: function() {
currentHookNameInDev = "useOpaqueIdentifier";
warnInvalidHookAccess();
@ -14246,7 +14421,7 @@ function updateForwardRef(
);
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
nextChildren = renderWithHooks(
@ -14258,7 +14433,7 @@ function updateForwardRef(
renderLanes
);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -14706,7 +14881,7 @@ function updateFunctionComponent(
);
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
nextChildren = renderWithHooks(
@ -14718,7 +14893,7 @@ function updateFunctionComponent(
renderLanes
);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -14916,12 +15091,12 @@ function finishClassComponent(
nextChildren = instance.render();
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
instance.render();
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
@ -15385,7 +15560,7 @@ function mountIndeterminateComponent(
{
if (workInProgress.mode & StrictLegacyMode) {
disableLogs();
setIsStrictModeForDevtools(true);
try {
value = renderWithHooks(
@ -15397,7 +15572,7 @@ function mountIndeterminateComponent(
renderLanes
);
} finally {
reenableLogs();
setIsStrictModeForDevtools(false);
}
}
}
@ -22870,6 +23045,7 @@ var shouldSuspendImpl = function(fiber) {
function shouldSuspend(fiber) {
return shouldSuspendImpl(fiber);
}
var isStrictMode = false;
var overrideHookState = null;
var overrideHookStateDeletePath = null;
var overrideHookStateRenamePath = null;
@ -23092,6 +23268,20 @@ function getCurrentFiberForDevTools() {
return current;
}
function getIsStrictModeForDevtools() {
return isStrictMode;
}
function setIsStrictModeForDevtools(newIsStrictMode) {
isStrictMode = newIsStrictMode;
{
if (newIsStrictMode) {
disableLogs();
} else {
reenableLogs();
}
}
}
function injectIntoDevTools(devToolsConfig) {
var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
@ -23120,6 +23310,7 @@ function injectIntoDevTools(devToolsConfig) {
setRefreshHandler: setRefreshHandler,
// Enables DevTools to append owner stacks to error messages in DEV mode.
getCurrentFiber: getCurrentFiberForDevTools,
getIsStrictMode: getIsStrictModeForDevtools,
// Enables DevTools to detect reconciler version rather than renderer version
// which may not match for third party renderers.
reconcilerVersion: ReactVersion

Просмотреть файл

@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<4b2938a7eccbcb5ebcaad8eeb6f50cee>>
* @generated SignedSource<<5efc4e18a211a1edf88bf8bd3a184783>>
*/
"use strict";
@ -3603,11 +3603,58 @@ function updateMutableSource(source, getSnapshot, subscribe) {
var hook = updateWorkInProgressHook();
return useMutableSource(hook, source, getSnapshot, subscribe);
}
function mountSyncExternalStore(subscribe, getSnapshot) {
var hook = mountWorkInProgressHook(),
nextSnapshot = getSnapshot();
hook.memoizedState = nextSnapshot;
var inst = { value: nextSnapshot, getSnapshot: getSnapshot };
hook.queue = inst;
return useSyncExternalStore(hook, inst, subscribe, getSnapshot, nextSnapshot);
}
function useSyncExternalStore(
hook,
inst,
subscribe,
getSnapshot,
nextSnapshot
) {
var fiber = currentlyRenderingFiber$1;
hook = ReactCurrentDispatcher$1.current;
hook.useLayoutEffect(
function() {
inst.value = nextSnapshot;
inst.getSnapshot = getSnapshot;
checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
},
[subscribe, nextSnapshot, getSnapshot]
);
hook.useEffect(
function() {
function handleStoreChange() {
checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
}
handleStoreChange();
return subscribe(handleStoreChange);
},
[subscribe]
);
return nextSnapshot;
}
function checkIfSnapshotChanged(inst) {
var latestGetSnapshot = inst.getSnapshot;
inst = inst.value;
try {
var nextValue = latestGetSnapshot();
return !objectIs(inst, nextValue);
} catch (error) {
return !0;
}
}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
hook.memoizedState = hook.baseState = initialState;
initialState = hook.queue = {
initialState = {
pending: null,
interleaved: null,
lanes: 0,
@ -3615,6 +3662,7 @@ function mountState(initialState) {
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
};
hook.queue = initialState;
initialState = initialState.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -3824,6 +3872,7 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
useSyncExternalStore: throwInvalidHookError,
useOpaqueIdentifier: throwInvalidHookError,
unstable_isNewReconciler: !1
},
@ -3861,7 +3910,7 @@ var ContextOnlyDispatcher = {
var hook = mountWorkInProgressHook();
initialArg = void 0 !== init ? init(initialArg) : initialArg;
hook.memoizedState = hook.baseState = initialArg;
reducer = hook.queue = {
reducer = {
pending: null,
interleaved: null,
lanes: 0,
@ -3869,6 +3918,7 @@ var ContextOnlyDispatcher = {
lastRenderedReducer: reducer,
lastRenderedState: initialArg
};
hook.queue = reducer;
reducer = reducer.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -3917,6 +3967,7 @@ var ContextOnlyDispatcher = {
};
return useMutableSource(hook, source, getSnapshot, subscribe);
},
useSyncExternalStore: mountSyncExternalStore,
useOpaqueIdentifier: function() {
throw Error("Not yet implemented");
},
@ -3960,6 +4011,19 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
useSyncExternalStore: function(subscribe, getSnapshot) {
var hook = updateWorkInProgressHook(),
nextSnapshot = getSnapshot();
objectIs(hook.memoizedState, nextSnapshot) ||
((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0));
return useSyncExternalStore(
hook,
hook.queue,
subscribe,
getSnapshot,
nextSnapshot
);
},
useOpaqueIdentifier: function() {
return updateReducer(basicStateReducer)[0];
},
@ -4003,6 +4067,7 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
useSyncExternalStore: mountSyncExternalStore,
useOpaqueIdentifier: function() {
return rerenderReducer(basicStateReducer)[0];
},
@ -8021,10 +8086,10 @@ batchedUpdatesImpl = function(fn, a) {
}
};
var roots = new Map(),
devToolsConfig$jscomp$inline_984 = {
devToolsConfig$jscomp$inline_989 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "18.0.0-bd5bf555e-20210823",
version: "18.0.0-95d762e40-20210908",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function() {
@ -8039,11 +8104,11 @@ var roots = new Map(),
}.bind(null, findNodeHandle)
}
};
var internals$jscomp$inline_1237 = {
bundleType: devToolsConfig$jscomp$inline_984.bundleType,
version: devToolsConfig$jscomp$inline_984.version,
rendererPackageName: devToolsConfig$jscomp$inline_984.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_984.rendererConfig,
var internals$jscomp$inline_1242 = {
bundleType: devToolsConfig$jscomp$inline_989.bundleType,
version: devToolsConfig$jscomp$inline_989.version,
rendererPackageName: devToolsConfig$jscomp$inline_989.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_989.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
@ -8059,26 +8124,27 @@ var internals$jscomp$inline_1237 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
devToolsConfig$jscomp$inline_984.findFiberByHostInstance ||
devToolsConfig$jscomp$inline_989.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.0.0-bd5bf555e-20210823"
getIsStrictMode: null,
reconcilerVersion: "18.0.0-95d762e40-20210908"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1238 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
var hook$jscomp$inline_1243 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
!hook$jscomp$inline_1238.isDisabled &&
hook$jscomp$inline_1238.supportsFiber
!hook$jscomp$inline_1243.isDisabled &&
hook$jscomp$inline_1243.supportsFiber
)
try {
(rendererID = hook$jscomp$inline_1238.inject(
internals$jscomp$inline_1237
(rendererID = hook$jscomp$inline_1243.inject(
internals$jscomp$inline_1242
)),
(injectedHook = hook$jscomp$inline_1238);
(injectedHook = hook$jscomp$inline_1243);
} catch (err) {}
}
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {

Просмотреть файл

@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<0c9b6f8df4fa2dc914b10ed49e47e8c7>>
* @generated SignedSource<<ad111484ca10270c3a7cd031b1e7fd26>>
*/
"use strict";
@ -3651,11 +3651,58 @@ function updateMutableSource(source, getSnapshot, subscribe) {
var hook = updateWorkInProgressHook();
return useMutableSource(hook, source, getSnapshot, subscribe);
}
function mountSyncExternalStore(subscribe, getSnapshot) {
var hook = mountWorkInProgressHook(),
nextSnapshot = getSnapshot();
hook.memoizedState = nextSnapshot;
var inst = { value: nextSnapshot, getSnapshot: getSnapshot };
hook.queue = inst;
return useSyncExternalStore(hook, inst, subscribe, getSnapshot, nextSnapshot);
}
function useSyncExternalStore(
hook,
inst,
subscribe,
getSnapshot,
nextSnapshot
) {
var fiber = currentlyRenderingFiber$1;
hook = ReactCurrentDispatcher$1.current;
hook.useLayoutEffect(
function() {
inst.value = nextSnapshot;
inst.getSnapshot = getSnapshot;
checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
},
[subscribe, nextSnapshot, getSnapshot]
);
hook.useEffect(
function() {
function handleStoreChange() {
checkIfSnapshotChanged(inst) && scheduleUpdateOnFiber(fiber, 1, -1);
}
handleStoreChange();
return subscribe(handleStoreChange);
},
[subscribe]
);
return nextSnapshot;
}
function checkIfSnapshotChanged(inst) {
var latestGetSnapshot = inst.getSnapshot;
inst = inst.value;
try {
var nextValue = latestGetSnapshot();
return !objectIs(inst, nextValue);
} catch (error) {
return !0;
}
}
function mountState(initialState) {
var hook = mountWorkInProgressHook();
"function" === typeof initialState && (initialState = initialState());
hook.memoizedState = hook.baseState = initialState;
initialState = hook.queue = {
initialState = {
pending: null,
interleaved: null,
lanes: 0,
@ -3663,6 +3710,7 @@ function mountState(initialState) {
lastRenderedReducer: basicStateReducer,
lastRenderedState: initialState
};
hook.queue = initialState;
initialState = initialState.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -3872,6 +3920,7 @@ var ContextOnlyDispatcher = {
useDeferredValue: throwInvalidHookError,
useTransition: throwInvalidHookError,
useMutableSource: throwInvalidHookError,
useSyncExternalStore: throwInvalidHookError,
useOpaqueIdentifier: throwInvalidHookError,
unstable_isNewReconciler: !1
},
@ -3909,7 +3958,7 @@ var ContextOnlyDispatcher = {
var hook = mountWorkInProgressHook();
initialArg = void 0 !== init ? init(initialArg) : initialArg;
hook.memoizedState = hook.baseState = initialArg;
reducer = hook.queue = {
reducer = {
pending: null,
interleaved: null,
lanes: 0,
@ -3917,6 +3966,7 @@ var ContextOnlyDispatcher = {
lastRenderedReducer: reducer,
lastRenderedState: initialArg
};
hook.queue = reducer;
reducer = reducer.dispatch = dispatchAction.bind(
null,
currentlyRenderingFiber$1,
@ -3965,6 +4015,7 @@ var ContextOnlyDispatcher = {
};
return useMutableSource(hook, source, getSnapshot, subscribe);
},
useSyncExternalStore: mountSyncExternalStore,
useOpaqueIdentifier: function() {
throw Error("Not yet implemented");
},
@ -4008,6 +4059,19 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
useSyncExternalStore: function(subscribe, getSnapshot) {
var hook = updateWorkInProgressHook(),
nextSnapshot = getSnapshot();
objectIs(hook.memoizedState, nextSnapshot) ||
((hook.memoizedState = nextSnapshot), (didReceiveUpdate = !0));
return useSyncExternalStore(
hook,
hook.queue,
subscribe,
getSnapshot,
nextSnapshot
);
},
useOpaqueIdentifier: function() {
return updateReducer(basicStateReducer)[0];
},
@ -4051,6 +4115,7 @@ var ContextOnlyDispatcher = {
return [isPending, start];
},
useMutableSource: updateMutableSource,
useSyncExternalStore: mountSyncExternalStore,
useOpaqueIdentifier: function() {
return rerenderReducer(basicStateReducer)[0];
},
@ -8454,10 +8519,10 @@ batchedUpdatesImpl = function(fn, a) {
}
};
var roots = new Map(),
devToolsConfig$jscomp$inline_1014 = {
devToolsConfig$jscomp$inline_1019 = {
findFiberByHostInstance: getInstanceFromTag,
bundleType: 0,
version: "18.0.0-bd5bf555e-20210823",
version: "18.0.0-95d762e40-20210908",
rendererPackageName: "react-native-renderer",
rendererConfig: {
getInspectorDataForViewTag: function() {
@ -8472,11 +8537,11 @@ var roots = new Map(),
}.bind(null, findNodeHandle)
}
};
var internals$jscomp$inline_1287 = {
bundleType: devToolsConfig$jscomp$inline_1014.bundleType,
version: devToolsConfig$jscomp$inline_1014.version,
rendererPackageName: devToolsConfig$jscomp$inline_1014.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_1014.rendererConfig,
var internals$jscomp$inline_1292 = {
bundleType: devToolsConfig$jscomp$inline_1019.bundleType,
version: devToolsConfig$jscomp$inline_1019.version,
rendererPackageName: devToolsConfig$jscomp$inline_1019.rendererPackageName,
rendererConfig: devToolsConfig$jscomp$inline_1019.rendererConfig,
overrideHookState: null,
overrideHookStateDeletePath: null,
overrideHookStateRenamePath: null,
@ -8492,26 +8557,27 @@ var internals$jscomp$inline_1287 = {
return null === fiber ? null : fiber.stateNode;
},
findFiberByHostInstance:
devToolsConfig$jscomp$inline_1014.findFiberByHostInstance ||
devToolsConfig$jscomp$inline_1019.findFiberByHostInstance ||
emptyFindFiberByHostInstance,
findHostInstancesForRefresh: null,
scheduleRefresh: null,
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.0.0-bd5bf555e-20210823"
getIsStrictMode: null,
reconcilerVersion: "18.0.0-95d762e40-20210908"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1288 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
var hook$jscomp$inline_1293 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
if (
!hook$jscomp$inline_1288.isDisabled &&
hook$jscomp$inline_1288.supportsFiber
!hook$jscomp$inline_1293.isDisabled &&
hook$jscomp$inline_1293.supportsFiber
)
try {
(rendererID = hook$jscomp$inline_1288.inject(
internals$jscomp$inline_1287
(rendererID = hook$jscomp$inline_1293.inject(
internals$jscomp$inline_1292
)),
(injectedHook = hook$jscomp$inline_1288);
(injectedHook = hook$jscomp$inline_1293);
} catch (err) {}
}
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {