mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
We originally had grand plans for using this Event concept for more but
now it's only meant to be used in combination with effects.
It's an Event in the FRP terms, that is triggered from an Effect.
Technically it can also be from another function that itself is
triggered from an existing side-effect but that's kind of an advanced
case.
The canonical case is an effect that triggers an event:
```js
const onHappened = useEffectEvent(() => ...);
useEffect(() => {
onHappened();
}, []);
```
88 lines
2.1 KiB
JavaScript
88 lines
2.1 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
|
|
*/
|
|
|
|
// Keep in sync with https://github.com/facebook/flow/blob/main/lib/react.js
|
|
export type StatelessFunctionalComponent<
|
|
P,
|
|
> = React$StatelessFunctionalComponent<P>;
|
|
export type ComponentType<-P> = React$ComponentType<P>;
|
|
export type AbstractComponent<
|
|
-Config,
|
|
+Instance = mixed,
|
|
> = React$AbstractComponent<Config, Instance>;
|
|
export type ElementType = React$ElementType;
|
|
export type Element<+C> = React$Element<C>;
|
|
export type Key = React$Key;
|
|
export type Ref<C> = React$Ref<C>;
|
|
export type Node = React$Node;
|
|
export type Context<T> = React$Context<T>;
|
|
export type Portal = React$Portal;
|
|
export type ElementProps<C> = React$ElementProps<C>;
|
|
export type ElementConfig<C> = React$ElementConfig<C>;
|
|
export type ElementRef<C> = React$ElementRef<C>;
|
|
export type Config<Props, DefaultProps> = React$Config<Props, DefaultProps>;
|
|
export type ChildrenArray<+T> = $ReadOnlyArray<ChildrenArray<T>> | T;
|
|
|
|
// Export all exports so that they're available in tests.
|
|
// We can't use export * from in Flow for some reason.
|
|
export {
|
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
act as unstable_act,
|
|
Children,
|
|
Component,
|
|
Fragment,
|
|
Profiler,
|
|
PureComponent,
|
|
StrictMode,
|
|
Suspense,
|
|
SuspenseList,
|
|
cloneElement,
|
|
createContext,
|
|
createElement,
|
|
createFactory,
|
|
createMutableSource,
|
|
createRef,
|
|
createServerContext,
|
|
use,
|
|
forwardRef,
|
|
isValidElement,
|
|
lazy,
|
|
memo,
|
|
cache,
|
|
startTransition,
|
|
unstable_Cache,
|
|
unstable_DebugTracingMode,
|
|
unstable_LegacyHidden,
|
|
unstable_Offscreen,
|
|
unstable_Scope,
|
|
unstable_TracingMarker,
|
|
unstable_getCacheSignal,
|
|
unstable_getCacheForType,
|
|
unstable_useCacheRefresh,
|
|
unstable_useMemoCache,
|
|
useId,
|
|
useCallback,
|
|
useContext,
|
|
useDebugValue,
|
|
useDeferredValue,
|
|
useEffect,
|
|
experimental_useEffectEvent,
|
|
useImperativeHandle,
|
|
useInsertionEffect,
|
|
useLayoutEffect,
|
|
useMemo,
|
|
useMutableSource,
|
|
useSyncExternalStore,
|
|
useReducer,
|
|
useRef,
|
|
useState,
|
|
useTransition,
|
|
version,
|
|
} from './src/React';
|