@deprecated —
export function createFactory<T extends HTMLElement>(type: keyof ReactHTML): HTMLFactory<T>@deprecated —
export function createFactory<P extends DOMAttributes<T>, T extends Element>(type: string): DOMFactory<P, T>@deprecated —
export function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>@deprecated —
export function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(type: ClassType<P, T, C>): CFactory<P, T>Lets you create a Context that components can provide or read.
@param — The value you want the context to have when there is no matching Provider in the tree above the component reading the context. This is meant as a "last resort" fallback.
@see — ://react.dev/reference/react/createContext#reference React Docs
@see — ://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet
@example — ```tsx import { createContext } from 'react';
const ThemeContext = createContext('light');
Lets your component expose a DOM node to a parent component using a ref.
@see — ://react.dev/reference/react/forwardRef React Docs
@see — ://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/ React TypeScript Cheatsheet
@param — See the ForwardRefRenderFunction.
@template — The type of the DOM node.
@template — The props the component accepts, if any.
@example — ```tsx interface Props { children?: ReactNode; type: "submit" | "button"; }
export const FancyButton = forwardRef<HTMLButtonElement, Props>((props, ref) => ( {props.children} ));
Lets you skip re-rendering a component when its props are unchanged.
@see — ://react.dev/reference/react/memo React Docs
@param — The component to memoize.
@param — A function that will be used to determine if the props have changed.
@example — ```tsx import { memo } from 'react';
const SomeComponent = memo(function SomeComponent(props: { foo: string }) { // ... });
Lets you defer loading a component’s code until it is rendered for the first time.
@see — ://react.dev/reference/react/lazy React Docs
@param — A function that returns a Promise
or another thenable (a Promise
-like object with a
then method). React will not call load
until the first time you attempt to render the returned
component. After React first calls load, it will wait for it to resolve, and then render the
resolved value’s .default
as a React component. Both the returned Promise
and the Promise
’s
resolved value will be cached, so React will not call load more than once. If the Promise
rejects,
React will throw the rejection reason for the nearest Error Boundary to handle.
@example — ```tsx import { lazy } from 'react';
const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
Accepts a context object (the value returned from React.createContext
) and returns the current
context value, as given by the nearest context provider for the given context.
@version — 16.8.0
@see — ://react.dev/reference/react/useContext
Returns a stateful value, and a function to update it.
@version — 16.8.0
@see — ://react.dev/reference/react/useState
Returns a stateful value, and a function to update it.
@version — 16.8.0
@see — ://react.dev/reference/react/useState
An alternative to useState
.
useReducer
is usually preferable to useState
when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch
down instead of callbacks.
@version — 16.8.0
@see — ://react.dev/reference/react/useReducer
An alternative to useState
.
useReducer
is usually preferable to useState
when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch
down instead of callbacks.
@version — 16.8.0
@see — ://react.dev/reference/react/useReducer
An alternative to useState
.
useReducer
is usually preferable to useState
when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch
down instead of callbacks.
@version — 16.8.0
@see — ://react.dev/reference/react/useReducer
An alternative to useState
.
useReducer
is usually preferable to useState
when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch
down instead of callbacks.
@version — 16.8.0
@see — ://react.dev/reference/react/useReducer
An alternative to useState
.
useReducer
is usually preferable to useState
when you have complex state logic that involves
multiple sub-values. It also lets you optimize performance for components that trigger deep
updates because you can pass dispatch
down instead of callbacks.
@version — 16.8.0
@see — ://react.dev/reference/react/useReducer
useRef
returns a mutable ref object whose .current
property is initialized to the passed argument
(initialValue
). The returned object will persist for the full lifetime of the component.
Note that useRef()
is useful for more than the ref
attribute. It’s handy for keeping any mutable
value around similar to how you’d use instance fields in classes.
@version — 16.8.0
@see — ://react.dev/reference/react/useRef
useRef
returns a mutable ref object whose .current
property is initialized to the passed argument
(initialValue
). The returned object will persist for the full lifetime of the component.
Note that useRef()
is useful for more than the ref
attribute. It’s handy for keeping any mutable
value around similar to how you’d use instance fields in classes.
Usage note: if you need the result of useRef to be directly mutable, include | null
in the type
of the generic argument.
@version — 16.8.0
@see — ://react.dev/reference/react/useRef
useRef
returns a mutable ref object whose .current
property is initialized to the passed argument
(initialValue
). The returned object will persist for the full lifetime of the component.
Note that useRef()
is useful for more than the ref
attribute. It’s handy for keeping any mutable
value around similar to how you’d use instance fields in classes.
@version — 16.8.0
@see — ://react.dev/reference/react/useRef
The signature is identical to useEffect
, but it fires synchronously after all DOM mutations.
Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
useLayoutEffect
will be flushed synchronously, before the browser has a chance to paint.
Prefer the standard useEffect
when possible to avoid blocking visual updates.
If you’re migrating code from a class component, useLayoutEffect
fires in the same phase as
componentDidMount
and componentDidUpdate
.
@version — 16.8.0
@see — ://react.dev/reference/react/useLayoutEffect
Accepts a function that contains imperative, possibly effectful code.
@param — Imperative function that can return a cleanup function
@param — If present, effect will only activate if the values in the list change.
@version — 16.8.0
@see — ://react.dev/reference/react/useEffect
useImperativeHandle
customizes the instance value that is exposed to parent components when using
ref
. As always, imperative code using refs should be avoided in most cases.
useImperativeHandle
should be used with React.forwardRef
.
@version — 16.8.0
@see — ://react.dev/reference/react/useImperativeHandle
useCallback
will return a memoized version of the callback that only changes if one of the inputs
has changed.
@version — 16.8.0
@see — ://react.dev/reference/react/useCallback
useMemo
will only recompute the memoized value when one of the deps
has changed.
@version — 16.8.0
@see — ://react.dev/reference/react/useMemo
useDebugValue
can be used to display a label for custom hooks in React DevTools.
NOTE: We don’t recommend adding debug values to every custom hook. It’s most valuable for custom hooks that are part of shared libraries.
@version — 16.8.0
@see — ://react.dev/reference/react/useDebugValue
Returns a deferred version of the value that may “lag behind” it.
This is commonly used to keep the interface responsive when you have something that renders immediately based on user input and something that needs to wait for a data fetch.
A good example of this is a text input.
@param — The value that is going to be deferred
@see — ://react.dev/reference/react/useDeferredValue
Allows components to avoid undesirable loading states by waiting for content to load before transitioning to the next screen. It also allows components to defer slower, data fetching updates until subsequent renders so that more crucial updates can be rendered immediately.
The useTransition
hook returns two values in an array.
The first is a boolean, React’s way of informing us whether we’re waiting for the transition to finish. The second is a function that takes a callback. We can use it to tell React which state we want to defer.
If some state update causes a component to suspend, that state update should be wrapped in a transition.
@see — ://react.dev/reference/react/useTransition
Similar to useTransition
but allows uses where hooks are not available.
@param — A synchronous function which causes state updates that can be deferred.
Wrap any code rendering and triggering updates to your components into act()
calls.
Ensures that the behavior in your tests matches what happens in the browser
more closely by executing pending useEffect
s before returning. This also
reduces the amount of re-renders done.
@param — A synchronous, void callback that will execute as a single, complete React commit.
@see — ://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
@param — Imperative function that can return a cleanup function
@param — If present, effect will only activate if the values in the list change.
@see — ://github.com/facebook/react/pull/21913
@param —
@param —
@see — ://github.com/reactwg/react-18/discussions/86
Used to retrieve the possible components which accept a given set of props.
Can be passed no type parameters to get a union of all possible components and tags.
Is a superset of ComponentType.
@template — The props to match against. If not passed, defaults to any.
@template — An optional tag to match against. If not passed, attempts to match against all possible tags.
@example — ```tsx
// All components and tags (img, embed etc.)
// which accept src
type SrcComponents = ElementType<{ src: any }>;
@example — ```tsx// All componentstype AllComponents = ElementType;
@example — ```tsx
// All custom components which match src
, and tags which
// match src
, narrowed down to just audio
and embed
type SrcComponents = ElementType<{ src: any }, 'audio' | 'embed'>;
Represents any user-defined component, either as a function or a class.
Similar to JSXElementConstructor, but with extra properties like defaultProps and contextTypes.
@template — The props the component accepts.
@see — ComponentClass
@see — FunctionComponent
Represents any user-defined component, either as a function or a class.
Similar to ComponentType, but without extra properties like defaultProps and contextTypes.
@template — The props the component accepts.
A readonly ref container where current cannot be mutated.
Created by createRef, or useRef when passed null
.
@template — The type of the ref's value.
@example — ```tsx const ref = createRef();
ref.current = document.createElement('div'); // Error
The current value of the ref.
readonly current: T | null;A callback fired whenever the ref's value changes.
@template — The type of the ref's value.
@see — ://react.dev/reference/react-dom/components/common#ref-callback React Docs
@example — ```tsx
A legacy implementation of refs where you can pass a string to a ref prop.
@see — ://react.dev/reference/react/Component#refs React Docs
@example — ```tsx
Retrieves the type of the 'ref' prop for a given component type or tag name.
@template — The component type.
@example — ```tsx type MyComponentRef = React.ElementRef;
@example — ```tsxtype DivRef = React.ElementRef<'div'>;
A value which uniquely identifies a node among items in an array.
@see — ://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs
@internal — The props any component can receive. You don't have to add this type. All components automatically accept these props.
const Component = () => <div />;<Component key="one" />
WARNING: The implementation of a component will never have access to these attributes.
The following example would be incorrect usage because Component would never have access to key
:
const Component = (props: React.Attributes) => props.key;
The props any component accepting refs can receive.
Class components, built-in browser components (e.g. div
) and forwardRef components can receive refs and automatically accept these props.
const Component = forwardRef(() => <div />);<Component ref={(current) => console.log(current)} />
You only need this type if you manually author the types of props that need to be compatible with legacy refs.
interface Props extends React.RefAttributes<HTMLDivElement> {}declare const Component: React.FunctionComponent<Props>;
Otherwise it's simpler to directly use Ref since you can safely use the props type to describe to props that a consumer can pass to the component as well as describing the props the implementation of a component "sees". RefAttributes is generally not safe to describe both consumer and seen props.
interface Props extends {ref?: React.Ref<HTMLDivElement> | undefined;}declare const Component: React.FunctionComponent<Props>;
WARNING: The implementation of a component will not have access to the same type in versions of React supporting string refs.
The following example would be incorrect usage because Component would never have access to a ref
with type string
const Component = (props: React.RefAttributes) => props.ref;
Allows getting a ref to the component instance.
Once the component unmounts, React will set ref.current
to null
(or call the ref with null
if you passed a callback ref).
@see — ://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs
Represents the built-in attributes available to class components.
export interface ClassAttributes<T> extends RefAttributes<T> {}Represents a JSX element.
Where ReactNode represents everything that can be rendered, ReactElement
only represents JSX.
@template — The type of the props object
@template — The type of the component or tag
@example — ```tsx const element: ReactElement = ;
@deprecated —
export interface ReactComponentElement<T extends keyof IntrinsicElements | JSXElementConstructor<any>, P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, "key" | "ref">>> extends ReactElement<P, Exclude<T, number>> {}@deprecated — Use ComponentElement instead.
export type ClassicElement<P> = CElement<P, ClassicComponent<P, ComponentState>>@deprecated — Please use FunctionComponentFactory
@deprecated — - This type is not relevant when using React. Inline the type instead to make the intent clear.
export type ReactText = string | number@deprecated — - This type is not relevant when using React. Inline the type instead to make the intent clear.
export type ReactChild = ReactElement | string | number@deprecated — Use either ReactNode[]
if you need an array or Iterable<ReactNode>
if its passed to a host component.
Different release channels declare additional types of ReactNode this particular release channel accepts. App or library types should never augment this interface.
export interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {}Represents all of the things React can render.
Where ReactElement only represents JSX, ReactNode
represents everything that can be rendered.
@see — ://react-typescript-cheatsheet.netlify.app/docs/react-types/reactnode/ React TypeScript Cheatsheet
@example — ```tsx // Typing children type Props = { children: ReactNode }
const Component = ({ children }: Props) => {children}
hello
@example — ```tsx// Typing a custom elementtype Props = { customElement: ReactNode }const Component = ({ customElement }: Props) => <div>{customElement}</div><Component customElement={<div>hello</div>} />
An object masquerading as a component. These are created by functions like forwardRef, memo, and createContext.
In order to make TypeScript work, we pretend that they are normal components.
But they are, in fact, not callable - instead, they are objects which are treated specially by the renderer.
@template — The props the component accepts.
An ExoticComponent with a displayName
property applied to it.
@template — The props the component accepts.
Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.
@see — ://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs
An ExoticComponent with a propTypes
property applied to it.
@template — The props the component accepts.
Used to retrieve the type of a context object from a Context.
@template — The context object.
@example — ```tsx import { createContext } from 'react';
const MyContext = createContext({ foo: 'bar' });
type ContextType = ContextType; // ContextType = { foo: string }
Wraps your components to specify the value of this context for all components inside.
@see — ://react.dev/reference/react/createContext#provider React Docs
@example — ```tsx import { createContext } from 'react';
const ThemeContext = createContext('light');
function App() { return ( <ThemeContext.Provider value="dark"> </ThemeContext.Provider> ); }
The old way to read context, before useContext existed.
@see — ://react.dev/reference/react/createContext#consumer React Docs
@example — ```tsx import { UserContext } from './user-context';
function Avatar() { return ( <UserContext.Consumer> {user => } </UserContext.Consumer> ); }
Context lets components pass information deep down without explicitly passing props.
Created from createContext
@see — ://react.dev/learn/passing-data-deeply-with-context React Docs
@see — ://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet
@example — ```tsx import { createContext } from 'react';
const ThemeContext = createContext('light');
Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.
@see — ://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs
Maintainer's note: Sync with ReactChildren until ReactChildren is removed.
export const Children: {Lets you group elements without a wrapper node.
@see — ://react.dev/reference/react/Fragment React Docs
@example — ```tsx import { Fragment } from 'react';
@example — ```tsx // Using the <></> shorthand syntax:
<>
Lets you find common bugs in your components early during development.
@see — ://react.dev/reference/react/StrictMode React Docs
@example — ```tsx import { StrictMode } from 'react';
The props accepted by Suspense.
@see — ://react.dev/reference/react/Suspense React Docs
A name for this Suspense boundary for instrumentation purposes. The name will help identify this boundary in React DevTools.
name?: string | undefined;Lets you display a fallback until its children have finished loading.
@see — ://react.dev/reference/react/Suspense React Docs
@example — ```tsx import { Suspense } from 'react';
<Suspense fallback={}>
The callback passed to onRender.
@see — ://react.dev/reference/react/Profiler#onrender-callback React Docs
The props accepted by Profiler.
@see — ://react.dev/reference/react/Profiler React Docs
Lets you measure rendering performance of a React tree programmatically.
@see — ://react.dev/reference/react/Profiler#onrender-callback React Docs
@example — ```tsx
@deprecated —
@see — ://legacy.reactjs.org/docs/legacy-context.html React Docs
If set, this.context
will be set at runtime to the current value of the given Context.
@example — ```ts type MyContext = number const Ctx = React.createContext(0)
class Foo extends React.Component { static contextType = Ctx context!: React.ContextType render () { return <>My context's value: {this.context}</>; } }
@see — ://react.dev/reference/react/Component#static-contexttype
If using the new style context, re-declare this in your class to be the
React.ContextType
of your static contextType
.
Should be used with type annotation or static contextType.
@example — ```ts static contextType = MyContext // For TS pre-3.7: context!: React.ContextType // For TS 3.7 and above: declare context: React.ContextType
@see — ://react.dev/reference/react/Component#context React Docs
@deprecated —
@see — ://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs Legacy React Docs
@deprecated — Use ClassicComponent
from create-react-class
@see — ://legacy.reactjs.org/docs/react-without-es6.html Legacy React Docs
@see — ://www.npmjs.com/package/create-react-class create-react-class
on npm
Represents the type of a function component. Can optionally receive a type argument that represents the props the component receives.
@template — The props the component accepts.
@see — ://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components React TypeScript Cheatsheet
@alias — for FunctionComponent
@example — ```tsx // With props: type Props = { name: string }
const MyComponent: FC = (props) => { return {props.name} }
@example — ```tsx// Without props:const MyComponentWithoutProps: FC = () => {return <div>MyComponentWithoutProps</div>}
Represents the type of a function component. Can optionally receive a type argument that represents the props the component accepts.
@template — The props the component accepts.
@see — ://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components React TypeScript Cheatsheet
@example — ```tsx // With props: type Props = { name: string }
const MyComponent: FunctionComponent = (props) => { return {props.name} }
@example — ```tsx// Without props:const MyComponentWithoutProps: FunctionComponent = () => {return <div>MyComponentWithoutProps</div>}
Used to declare the types of the props accepted by the component. These types will be checked during rendering and in development only.
We recommend using TypeScript instead of checking prop types at runtime.
@see — ://react.dev/reference/react/Component#static-proptypes React Docs
@deprecated — Lets you specify which legacy context is consumed by this component.
@see — ://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs
Used to define default values for the props accepted by the component.
@see — ://react.dev/reference/react/Component#static-defaultprops React Docs
@example — ```tsx type Props = { name?: string }
const MyComponent: FC = (props) => { return {props.name} }
MyComponent.defaultProps = { name: 'John Doe' }
@deprecated — Use ://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead.
Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.
@see — ://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs
@example — ```tsx
const MyComponent: FC = () => { return Hello! }
MyComponent.displayName = 'MyAwesomeComponent'
@deprecated — - Equivalent to FunctionComponent.
@see — FunctionComponent
@alias — VoidFunctionComponent
@deprecated — - Equivalent to FunctionComponent.
@see — FunctionComponent
@deprecated — Use ://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead.
defaultProps?: Partial<P> | undefined;The type of the ref received by a ForwardRefRenderFunction.
@see — ForwardRefRenderFunction
The type of the function passed to forwardRef. This is considered different to a normal FunctionComponent because it receives an additional argument,
@param — Props passed to the component, if any.
@param — A ref forwarded to the component of type ForwardedRef.
@template — The type of the forwarded ref.
@template — The type of the props the component accepts.
@see — ://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/ React TypeScript Cheatsheet
@see — forwardRef
Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.
Will show ForwardRef(${Component.displayName || Component.name})
in devtools by default, but can be given its own specific name.
@see — ://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs
defaultProps are not supported on render functions passed to forwardRef.
@see — ://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue for context
@see — ://react.dev/reference/react/Component#static-defaultprops React Docs
propTypes are not supported on render functions passed to forwardRef.
@see — ://github.com/microsoft/TypeScript/issues/36826 linked GitHub issue for context
@see — ://react.dev/reference/react/Component#static-proptypes React Docs
Represents a component class in React.
@template — The props the component accepts.
@template — The internal state of the component.
Used to declare the types of the props accepted by the component. These types will be checked during rendering and in development only.
We recommend using TypeScript instead of checking prop types at runtime.
@see — ://react.dev/reference/react/Component#static-proptypes React Docs
@deprecated — use contextType instead
Lets you specify which legacy context is consumed by this component.
@see — ://legacy.reactjs.org/docs/legacy-context.html Legacy React Docs
@deprecated —
@see — ://legacy.reactjs.org/docs/legacy-context.html#how-to-use-context Legacy React Docs
Used to define default values for the props accepted by the component.
@see — ://react.dev/reference/react/Component#static-defaultprops React Docs
Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.
@see — ://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs
@deprecated — Use ClassicComponentClass
from create-react-class
@see — ://legacy.reactjs.org/docs/react-without-es6.html Legacy React Docs
@see — ://www.npmjs.com/package/create-react-class create-react-class
on npm
Used in createElement and createFactory to represent a class.
An intersection type is used to infer multiple type parameters from a single argument, which is useful for many top-level API defs. See ://github.com/Microsoft/TypeScript/issues/7234 this GitHub issue for more info.
Called immediately after a component is mounted. Setting state here will trigger re-rendering.
componentDidMount(): void;Called to determine whether the change in props and state should trigger a re-render.
Component
always returns true.
PureComponent
implements a shallow comparison on props and state and returns true if any
props or states have changed.
If false is returned, render, componentWillUpdate
and componentDidUpdate
will not be called.
Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as
cancelled network requests, or cleaning up any DOM elements created in componentDidMount
.
Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;Runs before React applies the result of render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before render causes changes to it.
Note: the presence of this method prevents any of the deprecated lifecycle events from running.
Called immediately after updating occurs. Not called for the initial render.
The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
Called immediately before mounting occurs, and before render. Avoid introducing any side-effects or subscriptions in this method.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
@deprecated — 16.3, use componentDidMount or the constructor instead; will stop working in React 17
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
Called immediately before mounting occurs, and before render. Avoid introducing any side-effects or subscriptions in this method.
This method will not stop working in React 17.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
@deprecated — 16.3, use componentDidMount or the constructor instead
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
Called when the component may be receiving new props. React may call this even if props have not changed, so be sure to compare new and existing props if you only want to handle changes.
Calling setState generally does not trigger this method.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
@deprecated — 16.3, use static getDerivedStateFromProps instead; will stop working in React 17
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
Called when the component may be receiving new props. React may call this even if props have not changed, so be sure to compare new and existing props if you only want to handle changes.
Calling setState generally does not trigger this method.
This method will not stop working in React 17.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
@deprecated — 16.3, use static getDerivedStateFromProps instead
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
Called immediately before rendering when new props or state is received. Not called for the initial render.
Note: You cannot call setState here.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
@deprecated — 16.3, use getSnapshotBeforeUpdate instead; will stop working in React 17
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
Called immediately before rendering when new props or state is received. Not called for the initial render.
Note: You cannot call setState here.
This method will not stop working in React 17.
Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps prevents this from being invoked.
@deprecated — 16.3, use getSnapshotBeforeUpdate instead
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update
@see — ://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
@deprecated —
@see — ://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html Mixins Considered Harmful
The type of the component returned from forwardRef.
@template — The props the component accepts, if any.
@see — ExoticComponent
@deprecated — Use ://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead.
defaultProps?: Partial<P> | undefined;Omits the 'ref' attribute from the given props object.
@template — The props object type.
Ensures that the props do not include string ref, which cannot be forwarded
export type PropsWithRef<P> = "ref" extends keyof P ? P extends {Used to retrieve the props a component accepts. Can either be passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the type of a React component.
It's usually better to use ComponentPropsWithRef or ComponentPropsWithoutRef
instead of this type, as they let you be explicit about whether or not to include
the ref
prop.
@see — ://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet
@example — ```tsx // Retrieves the props an 'input' element accepts type InputProps = React.ComponentProps<'input'>;
@example — ```tsxconst MyComponent = (props: { foo: number, bar: string }) => <div />;// Retrieves the props 'MyComponent' acceptstype MyComponentProps = React.ComponentProps<typeof MyComponent>;
Used to retrieve the props a component accepts with its ref. Can either be passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the type of a React component.
@see — ://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet
@example — ```tsx // Retrieves the props an 'input' element accepts type InputProps = React.ComponentPropsWithRef<'input'>;
@example — ```tsxconst MyComponent = (props: { foo: number, bar: string }) => <div />;// Retrieves the props 'MyComponent' acceptstype MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
Used to retrieve the props a custom component accepts with its ref.
Unlike ComponentPropsWithRef, this only works with custom components, i.e. components you define yourself. This is to improve type-checking performance.
@example — ```tsx const MyComponent = (props: { foo: number, bar: string }) => ;
// Retrieves the props 'MyComponent' accepts type MyComponentPropsWithRef = React.CustomComponentPropsWithRef;
Used to retrieve the props a component accepts without its ref. Can either be passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the type of a React component.
@see — ://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet
@example — ```tsx // Retrieves the props an 'input' element accepts type InputProps = React.ComponentPropsWithoutRef<'input'>;
@example — ```tsxconst MyComponent = (props: { foo: number, bar: string }) => <div />;// Retrieves the props 'MyComponent' acceptstype MyComponentPropsWithoutRef = React.ComponentPropsWithoutRef<typeof MyComponent>;
The instruction passed to a Dispatch function in useState to tell React what the next value of the useState should be.
Often found wrapped in Dispatch.
@template — The type of the state.
@example — ```tsx
// This return type correctly represents the type of
// setCount
in the example below.
const useCustomState = (): Dispatch<SetStateAction> => {
const [count, setCount] = useState(0);
return setCount; }
A function that can be used to update the state of a useState or useReducer hook.
export type Dispatch<A> = (value: A) => voidA Dispatch function can sometimes be called without any arguments.
export type DispatchWithoutAction = () => voidThe function returned from an effect passed to useEffect, which can be used to clean up the effect when the component unmounts.
@see — ://react.dev/reference/react/useEffect React Docs
State updates caused inside the callback are allowed to be deferred.
If some state update causes a component to suspend, that state update should be wrapped in a transition.
@param — A synchronous function which causes state updates that can be deferred.
currentTarget - a reference to the element on which the event listener is registered.
target - a reference to the element from which the event was originally dispatched.
This might be a child element to the element on which the event listener is registered.
If you thought this should be EventTarget & T
, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11508#issuecomment-256045682
@deprecated —
charCode: number;See DOM Level 3 Events spec. for a list of valid (case-sensitive) arguments to this method.
getModifierState(key: ModifierKey): boolean;@deprecated —
keyCode: number;@deprecated —
which: number;See DOM Level 3 Events spec. for a list of valid (case-sensitive) arguments to this method.
getModifierState(key: ModifierKey): boolean;See DOM Level 3 Events spec. for a list of valid (case-sensitive) arguments to this method.
getModifierState(key: ModifierKey): boolean;@deprecated — Use onKeyUpCapture
or onKeyDownCapture
instead
Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.
"aria-activedescendant"?: string | undefined;Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.
"aria-atomic"?: Booleanish | undefined;Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be presented if they are made.
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user.
Defines a string value that labels the current element, which is intended to be converted into Braille.
@see —
Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille.
@see —
Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
@see —
@see —
Defines the total number of columns in a table, grid, or treegrid.
@see —
Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
@see —
@see —
Defines a human readable text alternative of aria-colindex.
@see —
Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
@see —
@see —
Identifies the element (or elements) whose contents or presence are controlled by the current element.
@see —
Indicates the element that represents the current item within a container or set of related elements.
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;Identifies the element (or elements) that describes the object.
@see —
Defines a string value that describes or annotates the current element.
@see — aria-describedby.
Identifies the element that provides a detailed, extended description for the object.
@see —
Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
@see —
@see —
Indicates what functions can be performed when a dragged object is released on the drop target.
@deprecated — in ARIA 1.1
Identifies the element that provides an error message for the object.
@see —
@see —
Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.
"aria-expanded"?: Booleanish | undefined;Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, allows assistive technology to override the general default of reading in document source order.
"aria-flowto"?: string | undefined;Indicates an element's "grabbed" state in a drag-and-drop operation.
@deprecated — in ARIA 1.1
Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;Indicates whether the element is exposed to an accessibility API.
@see —
Indicates the entered value does not conform to the format expected by the application.
@see —
Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.
"aria-keyshortcuts"?: string | undefined;Defines a string value that labels the current element.
@see —
Identifies the element (or elements) that labels the current element.
@see —
Defines the hierarchical level of an element within a structure.
"aria-level"?: number | undefined;Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.
"aria-live"?: "off" | "assertive" | "polite" | undefined;Indicates whether a text box accepts multiple lines of input or only a single line.
"aria-multiline"?: Booleanish | undefined;Indicates that the user may select more than one item from the current selectable descendants.
"aria-multiselectable"?: Booleanish | undefined;Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.
"aria-orientation"?: "horizontal" | "vertical" | undefined;Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
@see —
Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. A hint could be a sample value or a brief description of the expected format.
"aria-placeholder"?: string | undefined;Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
@see —
Indicates the current "pressed" state of toggle buttons.
@see —
@see —
Indicates that the element is not editable, but is otherwise operable.
@see —
Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
@see —
Indicates that user input is required on the element before a form may be submitted.
"aria-required"?: Booleanish | undefined;Defines a human-readable, author-localized description for the role of an element.
"aria-roledescription"?: string | undefined;Defines the total number of rows in a table, grid, or treegrid.
@see —
Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
@see —
@see —
Defines a human readable text alternative of aria-rowindex.
@see —
Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
@see —
@see —
Indicates the current "selected" state of various widgets.
@see —
@see —
Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.
@see —
Indicates if items in a table or grid are sorted in ascending or descending order.
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;Defines the maximum allowed value for a range widget.
"aria-valuemax"?: number | undefined;Defines the minimum allowed value for a range widget.
"aria-valuemin"?: number | undefined;Defines the current value for a range widget.
@see —
Defines the human readable text alternative of aria-valuenow for a range widget.
"aria-valuetext"?: string | undefined;Used to represent DOM API's where users can either pass true or false as a boolean or as its equivalent strings.
type Booleanish = boolean | "true" | "false"Hints at the type of data that might be entered by the user while editing the element or its contents
@see — ://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute
Specify that a standard HTML element should behave like a defined custom built-in element
@see — ://html.spec.whatwg.org/multipage/custom-elements.html#attr-is
For internal usage only. Different release channels declare additional types of ReactNode this particular release channel accepts. App or library types should never augment this interface.
export interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS {}@see — ://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin MDN
type CrossOrigin = "anonymous" | "use-credentials" | "" | undefined@deprecated —
frameBorder?: number | string | undefined;@deprecated —
marginHeight?: number | undefined;@deprecated —
marginWidth?: number | undefined;@deprecated —
scrolling?: string | undefined;@deprecated —
charSet?: string | undefined;@deprecated — Use Validator
from the ´prop-types` instead.
@deprecated — Use Requireable
from the ´prop-types` instead.
@deprecated — Use ValidationMap
from the ´prop-types` instead.
@deprecated — Use PropTypes.*
where PropTypes
comes from import * as PropTypes from 'prop-types'
instead.
@deprecated — - Use typeof React.Children
instead.
Captures which component contained the exception, and its ancestors.
componentStack?: string | null;Create a React element.
You should not use this function directly. Use JSX and a transpiler instead.
Create a React element.
You should not use this function directly. Use JSX and a transpiler instead.
Create a React element.
You should not use this function directly. Use JSX and a transpiler instead.
The source file where the element originates from.
fileName?: string | undefined;The line number where the element was created.
lineNumber?: number | undefined;The column number where the element was created.
columnNumber?: number | undefined;