I don't think we're ready to land this yet since we're using it to run other experiments and our tests. I'm opening this PR to indicate intent to disable and to ensure tests in other combinations still work. Such as enableHalt without enablePostpone. I think we'll also need to rewrite some tests that depend on enablePostpone to preserve some coverage. The conclusion after this experiment is that try/catch around these are too likely to block these signals and consider them error. Throwing works for Hooks and `use()` because the lint rule can ensure that they're not wrapped in try/catch. Throwing in arbitrary functions not quite ecosystem compatible. It's also why there's `use()` and not just throwing a Promise. This might also affect the Catch proposal. The "prerender" for SSR that's supporting "Partial Prerendering" is still there. This just disables the `React.postpone()` API for creating the holes.
76 lines
1.5 KiB
JavaScript
76 lines
1.5 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
export {
|
|
__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
__COMPILER_RUNTIME,
|
|
Children,
|
|
Component,
|
|
Fragment,
|
|
Profiler,
|
|
PureComponent,
|
|
StrictMode,
|
|
Suspense,
|
|
cloneElement,
|
|
createContext,
|
|
createElement,
|
|
createRef,
|
|
use,
|
|
forwardRef,
|
|
isValidElement,
|
|
lazy,
|
|
memo,
|
|
cache,
|
|
cacheSignal,
|
|
startTransition,
|
|
Activity,
|
|
unstable_getCacheForType,
|
|
unstable_SuspenseList,
|
|
ViewTransition,
|
|
unstable_startGestureTransition,
|
|
addTransitionType,
|
|
unstable_useCacheRefresh,
|
|
useId,
|
|
useCallback,
|
|
useContext,
|
|
useDebugValue,
|
|
useDeferredValue,
|
|
useEffect,
|
|
useEffectEvent,
|
|
useImperativeHandle,
|
|
useInsertionEffect,
|
|
useLayoutEffect,
|
|
useMemo,
|
|
useOptimistic,
|
|
useReducer,
|
|
useRef,
|
|
useState,
|
|
useSyncExternalStore,
|
|
useTransition,
|
|
useActionState,
|
|
version,
|
|
act, // DEV-only
|
|
captureOwnerStack, // DEV-only
|
|
} from './src/ReactClient';
|
|
|
|
import {useOptimistic} from './src/ReactClient';
|
|
|
|
export function experimental_useOptimistic<S, A>(
|
|
passthrough: S,
|
|
reducer: ?(S, A) => S,
|
|
): [S, (A) => void] {
|
|
if (__DEV__) {
|
|
console.error(
|
|
'useOptimistic is now in canary. Remove the experimental_ prefix. ' +
|
|
'The prefixed alias will be removed in an upcoming release.',
|
|
);
|
|
}
|
|
return useOptimistic(passthrough, reducer);
|
|
}
|