Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/react-dom

Package Overview
Dependencies
Maintainers
1
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/react-dom - npm Package Compare versions

Comparing version 18.3.1 to 19.0.0

152

react-dom/canary.d.ts

@@ -33,153 +33,1 @@ /**

export {};
declare const REACT_FORM_STATE_SIGIL: unique symbol;
declare module "." {
function prefetchDNS(href: string): void;
interface PreconnectOptions {
// Don't create a helper type.
// It would have to be in module scope to be inlined in TS tooltips.
// But then it becomes part of the public API.
// TODO: Upstream to microsoft/TypeScript-DOM-lib-generator -> w3c/webref
// since the spec has a notion of a dedicated type: https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attribute
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
}
function preconnect(href: string, options?: PreconnectOptions): void;
type PreloadAs =
| "audio"
| "document"
| "embed"
| "fetch"
| "font"
| "image"
| "object"
| "track"
| "script"
| "style"
| "video"
| "worker";
interface PreloadOptions {
as: PreloadAs;
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
fetchPriority?: "high" | "low" | "auto" | undefined;
// TODO: These should only be allowed with `as: 'image'` but it's not trivial to write tests against the full TS support matrix.
imageSizes?: string | undefined;
imageSrcSet?: string | undefined;
integrity?: string | undefined;
type?: string | undefined;
nonce?: string | undefined;
referrerPolicy?: ReferrerPolicy | undefined;
}
function preload(href: string, options?: PreloadOptions): void;
// https://html.spec.whatwg.org/multipage/links.html#link-type-modulepreload
type PreloadModuleAs = RequestDestination;
interface PreloadModuleOptions {
/**
* @default "script"
*/
as: PreloadModuleAs;
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
integrity?: string | undefined;
nonce?: string | undefined;
}
function preloadModule(href: string, options?: PreloadModuleOptions): void;
type PreinitAs = "script" | "style";
interface PreinitOptions {
as: PreinitAs;
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
fetchPriority?: "high" | "low" | "auto" | undefined;
precedence?: string | undefined;
integrity?: string | undefined;
nonce?: string | undefined;
}
function preinit(href: string, options?: PreinitOptions): void;
// Will be expanded to include all of https://github.com/tc39/proposal-import-attributes
type PreinitModuleAs = "script";
interface PreinitModuleOptions {
/**
* @default "script"
*/
as?: PreinitModuleAs;
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
integrity?: string | undefined;
nonce?: string | undefined;
}
function preinitModule(href: string, options?: PreinitModuleOptions): void;
interface FormStatusNotPending {
pending: false;
data: null;
method: null;
action: null;
}
interface FormStatusPending {
pending: true;
data: FormData;
method: string;
action: string | ((formData: FormData) => void | Promise<void>);
}
type FormStatus = FormStatusPending | FormStatusNotPending;
function useFormStatus(): FormStatus;
function useFormState<State>(
action: (state: Awaited<State>) => State | Promise<State>,
initialState: Awaited<State>,
permalink?: string,
): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
function useFormState<State, Payload>(
action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
initialState: Awaited<State>,
permalink?: string,
): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
function requestFormReset(form: HTMLFormElement): void;
}
declare module "./client" {
interface ReactFormState {
[REACT_FORM_STATE_SIGIL]: never;
}
interface RootOptions {
onUncaughtError?:
| ((error: unknown, errorInfo: { componentStack?: string | undefined }) => void)
| undefined;
onCaughtError?:
| ((
error: unknown,
errorInfo: {
componentStack?: string | undefined;
errorBoundary?: React.Component<unknown> | undefined;
},
) => void)
| undefined;
}
interface HydrationOptions {
formState?: ReactFormState | null;
onUncaughtError?:
| ((error: unknown, errorInfo: { componentStack?: string | undefined }) => void)
| undefined;
onCaughtError?:
| ((
error: unknown,
errorInfo: {
componentStack?: string | undefined;
errorBoundary?: React.Component<unknown> | undefined;
},
) => void)
| undefined;
}
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_CREATE_ROOT_CONTAINERS {
document: Document;
}
}

35

react-dom/client.d.ts

@@ -8,3 +8,12 @@ /**

import React = require("react");
export {};
declare const REACT_FORM_STATE_SIGIL: unique symbol;
export interface ReactFormState {
[REACT_FORM_STATE_SIGIL]: never;
}
export interface HydrationOptions {
formState?: ReactFormState | null;
/**

@@ -14,3 +23,15 @@ * Prefix for `useId`.

identifierPrefix?: string;
onUncaughtError?:
| ((error: unknown, errorInfo: { componentStack?: string | undefined }) => void)
| undefined;
onRecoverableError?: (error: unknown, errorInfo: ErrorInfo) => void;
onCaughtError?:
| ((
error: unknown,
errorInfo: {
componentStack?: string | undefined;
errorBoundary?: React.Component<unknown> | undefined;
},
) => void)
| undefined;
}

@@ -23,7 +44,18 @@

identifierPrefix?: string;
onUncaughtError?:
| ((error: unknown, errorInfo: { componentStack?: string | undefined }) => void)
| undefined;
onRecoverableError?: (error: unknown, errorInfo: ErrorInfo) => void;
onCaughtError?:
| ((
error: unknown,
errorInfo: {
componentStack?: string | undefined;
errorBoundary?: React.Component<unknown> | undefined;
},
) => void)
| undefined;
}
export interface ErrorInfo {
digest?: string;
componentStack?: string;

@@ -47,2 +79,3 @@ }

| DocumentFragment
| Document
| DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_CREATE_ROOT_CONTAINERS[

@@ -49,0 +82,0 @@ keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_CREATE_ROOT_CONTAINERS

@@ -7,25 +7,4 @@ // NOTE: Users of the `experimental` builds of React should add a reference

import {
CElement,
Component,
ComponentState,
DOMAttributes,
DOMElement,
FunctionComponentElement,
Key,
ReactElement,
ReactInstance,
ReactNode,
ReactPortal,
} from "react";
import { Key, ReactNode, ReactPortal } from "react";
/**
* @deprecated See https://react.dev/reference/react-dom/findDOMNode#alternatives
*/
export function findDOMNode(instance: ReactInstance | null | undefined): Element | null | Text;
/**
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
*/
export function unmountComponentAtNode(container: Element | DocumentFragment): boolean;
export function createPortal(

@@ -38,10 +17,2 @@ children: ReactNode,

export const version: string;
/**
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
*/
export const render: Renderer;
/**
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
*/
export const hydrate: Renderer;

@@ -53,101 +24,107 @@ export function flushSync<R>(fn: () => R): R;

/**
* @deprecated
*/
export function unstable_renderSubtreeIntoContainer<T extends Element>(
parentComponent: Component<any>,
element: DOMElement<DOMAttributes<T>, T>,
container: Element,
callback?: (element: T) => any,
): T;
/**
* @deprecated
*/
export function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>(
parentComponent: Component<any>,
element: CElement<P, T>,
container: Element,
callback?: (component: T) => any,
): T;
/**
* @deprecated
*/
export function unstable_renderSubtreeIntoContainer<P>(
parentComponent: Component<any>,
element: ReactElement<P>,
container: Element,
callback?: (component?: Component<P, ComponentState> | Element) => any,
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
): Component<P, ComponentState> | Element | void;
export interface FormStatusNotPending {
pending: false;
data: null;
method: null;
action: null;
}
export type Container = Element | Document | DocumentFragment;
export interface FormStatusPending {
pending: true;
data: FormData;
method: string;
action: string | ((formData: FormData) => void | Promise<void>);
}
export interface Renderer {
// Deprecated(render): The return value is deprecated.
// In future releases the render function's return type will be void.
export type FormStatus = FormStatusPending | FormStatusNotPending;
/**
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
*/
<T extends Element>(
element: DOMElement<DOMAttributes<T>, T>,
container: Container | null,
callback?: () => void,
): T;
export function useFormStatus(): FormStatus;
/**
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
*/
(
element: Array<DOMElement<DOMAttributes<any>, any>>,
container: Container | null,
callback?: () => void,
): Element;
export function useFormState<State>(
action: (state: Awaited<State>) => State | Promise<State>,
initialState: Awaited<State>,
permalink?: string,
): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
export function useFormState<State, Payload>(
action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
initialState: Awaited<State>,
permalink?: string,
): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
/**
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
*/
(
element: FunctionComponentElement<any> | Array<FunctionComponentElement<any>>,
container: Container | null,
callback?: () => void,
): void;
export function prefetchDNS(href: string): void;
/**
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
*/
<P, T extends Component<P, ComponentState>>(
element: CElement<P, T>,
container: Container | null,
callback?: () => void,
): T;
export interface PreconnectOptions {
// Don't create a helper type.
// It would have to be in module scope to be inlined in TS tooltips.
// But then it becomes part of the public API.
// TODO: Upstream to microsoft/TypeScript-DOM-lib-generator -> w3c/webref
// since the spec has a notion of a dedicated type: https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attribute
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
}
export function preconnect(href: string, options?: PreconnectOptions): void;
/**
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
*/
(
element: Array<CElement<any, Component<any, ComponentState>>>,
container: Container | null,
callback?: () => void,
): Component<any, ComponentState>;
export type PreloadAs =
| "audio"
| "document"
| "embed"
| "fetch"
| "font"
| "image"
| "object"
| "track"
| "script"
| "style"
| "video"
| "worker";
export interface PreloadOptions {
as: PreloadAs;
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
fetchPriority?: "high" | "low" | "auto" | undefined;
// TODO: These should only be allowed with `as: 'image'` but it's not trivial to write tests against the full TS support matrix.
imageSizes?: string | undefined;
imageSrcSet?: string | undefined;
integrity?: string | undefined;
type?: string | undefined;
nonce?: string | undefined;
referrerPolicy?: ReferrerPolicy | undefined;
}
export function preload(href: string, options?: PreloadOptions): void;
// https://html.spec.whatwg.org/multipage/links.html#link-type-modulepreload
export type PreloadModuleAs = RequestDestination;
export interface PreloadModuleOptions {
/**
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
* @default "script"
*/
<P>(
element: ReactElement<P>,
container: Container | null,
callback?: () => void,
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
): Component<P, ComponentState> | Element | void;
as: PreloadModuleAs;
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
integrity?: string | undefined;
nonce?: string | undefined;
}
export function preloadModule(href: string, options?: PreloadModuleOptions): void;
export type PreinitAs = "script" | "style";
export interface PreinitOptions {
as: PreinitAs;
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
fetchPriority?: "high" | "low" | "auto" | undefined;
precedence?: string | undefined;
integrity?: string | undefined;
nonce?: string | undefined;
}
export function preinit(href: string, options?: PreinitOptions): void;
// Will be expanded to include all of https://github.com/tc39/proposal-import-attributes
export type PreinitModuleAs = "script";
export interface PreinitModuleOptions {
/**
* @deprecated See https://react.dev/blog/2022/03/08/react-18-upgrade-guide#updates-to-client-rendering-apis
* @default "script"
*/
(
element: ReactElement[],
container: Container | null,
callback?: () => void,
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
): Component<any, ComponentState> | Element | void;
as?: PreinitModuleAs;
crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
integrity?: string | undefined;
nonce?: string | undefined;
}
export function preinitModule(href: string, options?: PreinitModuleOptions): void;
export function requestFormReset(form: HTMLFormElement): void;
{
"name": "@types/react-dom",
"version": "18.3.1",
"version": "19.0.0",
"description": "TypeScript definitions for react-dom",

@@ -85,4 +85,5 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom",

},
"typesPublisherContentHash": "a3dae397f083f79a977be3366dd86cfbcb7da67ad0089da69419978000ba6764",
"typeScriptVersion": "4.8"
"peerDependencies": {},
"typesPublisherContentHash": "bfa192efe4d902904df093f5cf45f5bfb86784036b0a929810713bb9fbd1c78c",
"typeScriptVersion": "5.0"
}

@@ -11,3 +11,3 @@ # Installation

### Additional Details
* Last updated: Fri, 11 Oct 2024 14:37:45 GMT
* Last updated: Thu, 05 Dec 2024 19:32:25 GMT
* Dependencies: [@types/react](https://npmjs.com/package/@types/react)

@@ -14,0 +14,0 @@

@@ -73,11 +73,2 @@ // forward declarations

/**
* Render a React element to its initial HTML. Returns a Readable stream that outputs
* an HTML string. The HTML output by this stream is exactly equal to what
* `ReactDOMServer.renderToString()` would return.
*
* @deprecated
*/
export function renderToNodeStream(element: ReactNode, options?: ServerOptions): NodeJS.ReadableStream;
/**
* Similar to `renderToString`, except this doesn't create extra DOM attributes

@@ -90,11 +81,2 @@ * such as `data-reactid`, that React uses internally. This is useful if you want

/**
* Similar to `renderToNodeStream`, except this doesn't create extra DOM attributes
* such as `data-reactid`, that React uses internally. The HTML output by this stream
* is exactly equal to what `ReactDOMServer.renderToStaticMarkup()` would return.
*
* @deprecated
*/
export function renderToStaticNodeStream(element: ReactNode, options?: ServerOptions): NodeJS.ReadableStream;
export interface RenderToReadableStreamOptions {

@@ -101,0 +83,0 @@ identifierPrefix?: string;

@@ -1,402 +0,7 @@

import {
AbstractView,
CElement,
ClassType,
Component,
ComponentClass,
DOMAttributes,
DOMElement,
FC,
FunctionComponentElement,
ReactElement,
ReactHTMLElement,
ReactInstance,
} from "react";
import * as ReactTestUtils from ".";
export {};
export interface OptionalEventProperties {
bubbles?: boolean | undefined;
cancelable?: boolean | undefined;
currentTarget?: EventTarget | undefined;
defaultPrevented?: boolean | undefined;
eventPhase?: number | undefined;
isTrusted?: boolean | undefined;
nativeEvent?: Event | undefined;
preventDefault?(): void;
stopPropagation?(): void;
target?: EventTarget | undefined;
timeStamp?: Date | undefined;
type?: string | undefined;
}
export type ModifierKey =
| "Alt"
| "AltGraph"
| "CapsLock"
| "Control"
| "Fn"
| "FnLock"
| "Hyper"
| "Meta"
| "NumLock"
| "ScrollLock"
| "Shift"
| "Super"
| "Symbol"
| "SymbolLock";
export interface SyntheticEventData extends OptionalEventProperties {
altKey?: boolean | undefined;
button?: number | undefined;
buttons?: number | undefined;
clientX?: number | undefined;
clientY?: number | undefined;
changedTouches?: TouchList | undefined;
charCode?: number | undefined;
clipboardData?: DataTransfer | undefined;
ctrlKey?: boolean | undefined;
deltaMode?: number | undefined;
deltaX?: number | undefined;
deltaY?: number | undefined;
deltaZ?: number | undefined;
detail?: number | undefined;
getModifierState?(key: ModifierKey): boolean;
key?: string | undefined;
keyCode?: number | undefined;
locale?: string | undefined;
location?: number | undefined;
metaKey?: boolean | undefined;
pageX?: number | undefined;
pageY?: number | undefined;
relatedTarget?: EventTarget | undefined;
repeat?: boolean | undefined;
screenX?: number | undefined;
screenY?: number | undefined;
shiftKey?: boolean | undefined;
targetTouches?: TouchList | undefined;
touches?: TouchList | undefined;
view?: AbstractView | undefined;
which?: number | undefined;
}
export type EventSimulator = (element: Element | Component<any>, eventData?: SyntheticEventData) => void;
export interface MockedComponentClass {
new(props: any): any;
}
export interface ShallowRenderer {
export {
/**
* After `shallowRenderer.render()` has been called, returns shallowly rendered output.
*/
getRenderOutput<E extends ReactElement>(): E;
/**
* Similar to `ReactDOM.render` but it doesn't require DOM and only renders a single level deep.
*/
render(element: ReactElement, context?: any): void;
unmount(): void;
}
/**
* Simulate an event dispatch on a DOM node with optional `eventData` event data.
* `Simulate` has a method for every event that React understands.
*/
export namespace Simulate {
const abort: EventSimulator;
const animationEnd: EventSimulator;
const animationIteration: EventSimulator;
const animationStart: EventSimulator;
const blur: EventSimulator;
const cancel: EventSimulator;
const canPlay: EventSimulator;
const canPlayThrough: EventSimulator;
const change: EventSimulator;
const click: EventSimulator;
const close: EventSimulator;
const compositionEnd: EventSimulator;
const compositionStart: EventSimulator;
const compositionUpdate: EventSimulator;
const contextMenu: EventSimulator;
const copy: EventSimulator;
const cut: EventSimulator;
const auxClick: EventSimulator;
const doubleClick: EventSimulator;
const drag: EventSimulator;
const dragEnd: EventSimulator;
const dragEnter: EventSimulator;
const dragExit: EventSimulator;
const dragLeave: EventSimulator;
const dragOver: EventSimulator;
const dragStart: EventSimulator;
const drop: EventSimulator;
const durationChange: EventSimulator;
const emptied: EventSimulator;
const encrypted: EventSimulator;
const ended: EventSimulator;
const error: EventSimulator;
const focus: EventSimulator;
const input: EventSimulator;
const invalid: EventSimulator;
const keyDown: EventSimulator;
const keyPress: EventSimulator;
const keyUp: EventSimulator;
const load: EventSimulator;
const loadStart: EventSimulator;
const loadedData: EventSimulator;
const loadedMetadata: EventSimulator;
const mouseDown: EventSimulator;
const mouseEnter: EventSimulator;
const mouseLeave: EventSimulator;
const mouseMove: EventSimulator;
const mouseOut: EventSimulator;
const mouseOver: EventSimulator;
const mouseUp: EventSimulator;
const paste: EventSimulator;
const pause: EventSimulator;
const play: EventSimulator;
const playing: EventSimulator;
const progress: EventSimulator;
const pointerCancel: EventSimulator;
const pointerDown: EventSimulator;
const pointerUp: EventSimulator;
const pointerMove: EventSimulator;
const pointerOut: EventSimulator;
const pointerOver: EventSimulator;
const pointerEnter: EventSimulator;
const pointerLeave: EventSimulator;
const gotPointerCapture: EventSimulator;
const lostPointerCapture: EventSimulator;
const rateChange: EventSimulator;
const reset: EventSimulator;
const resize: EventSimulator;
const scroll: EventSimulator;
const toggle: EventSimulator;
const seeked: EventSimulator;
const seeking: EventSimulator;
const select: EventSimulator;
const beforeInput: EventSimulator;
const stalled: EventSimulator;
const submit: EventSimulator;
const suspend: EventSimulator;
const timeUpdate: EventSimulator;
const touchCancel: EventSimulator;
const touchEnd: EventSimulator;
const touchMove: EventSimulator;
const touchStart: EventSimulator;
const transitionEnd: EventSimulator;
const volumeChange: EventSimulator;
const waiting: EventSimulator;
const wheel: EventSimulator;
}
/**
* Render a React element into a detached DOM node in the document. __This function requires a DOM__.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function renderIntoDocument<T extends Element>(
element: DOMElement<any, T>,
): T;
/** @deprecated https://react.dev/warnings/react-dom-test-utils */
export function renderIntoDocument(
element: FunctionComponentElement<any>,
): void;
// If we replace `P` with `any` in this overload, then some tests fail because
// calls to `renderIntoDocument` choose the last overload on the
// subtype-relation pass and get an undesirably broad return type. Using `P`
// allows this overload to match on the subtype-relation pass.
/**
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function renderIntoDocument<P, T extends Component<P>>(
element: CElement<P, T>,
): T;
/**
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function renderIntoDocument<P>(
element: ReactElement<P>,
): Component<P> | Element | void;
/**
* Pass a mocked component module to this method to augment it with useful methods that allow it to
* be used as a dummy React component. Instead of rendering as usual, the component will become
* a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function mockComponent(
mocked: MockedComponentClass,
mockTagName?: string,
): typeof ReactTestUtils;
/**
* Returns `true` if `element` is any React element.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function isElement(element: any): boolean;
/**
* Returns `true` if `element` is a React element whose type is of a React `componentClass`.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function isElementOfType<T extends HTMLElement>(
element: ReactElement,
type: string,
): element is ReactHTMLElement<T>;
/**
* Returns `true` if `element` is a React element whose type is of a React `componentClass`.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function isElementOfType<P extends DOMAttributes<{}>, T extends Element>(
element: ReactElement,
type: string,
): element is DOMElement<P, T>;
/**
* Returns `true` if `element` is a React element whose type is of a React `componentClass`.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function isElementOfType<P>(
element: ReactElement,
type: FC<P>,
): element is FunctionComponentElement<P>;
/**
* Returns `true` if `element` is a React element whose type is of a React `componentClass`.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function isElementOfType<P, T extends Component<P>, C extends ComponentClass<P>>(
element: ReactElement,
type: ClassType<P, T, C>,
): element is CElement<P, T>;
/**
* Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function isDOMComponent(instance: ReactInstance): instance is Element;
/**
* Returns `true` if `instance` is a user-defined component, such as a class or a function.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function isCompositeComponent(instance: ReactInstance): instance is Component<any>;
/**
* Returns `true` if `instance` is a component whose type is of a React `componentClass`.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function isCompositeComponentWithType<T extends Component<any>, C extends ComponentClass<any>>(
instance: ReactInstance,
type: ClassType<any, T, C>,
): boolean;
/**
* Traverse all components in `tree` and accumulate all components where
* `test(component)` is `true`. This is not that useful on its own, but it's used
* as a primitive for other test utils.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function findAllInRenderedTree(
root: Component<any>,
fn: (i: ReactInstance) => boolean,
): ReactInstance[];
/**
* Finds all DOM elements of components in the rendered tree that are
* DOM components with the class name matching `className`.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function scryRenderedDOMComponentsWithClass(
root: Component<any>,
className: string,
): Element[];
/**
* Like `scryRenderedDOMComponentsWithClass()` but expects there to be one result,
* and returns that one result, or throws exception if there is any other
* number of matches besides one.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function findRenderedDOMComponentWithClass(
root: Component<any>,
className: string,
): Element;
/**
* Finds all DOM elements of components in the rendered tree that are
* DOM components with the tag name matching `tagName`.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function scryRenderedDOMComponentsWithTag(
root: Component<any>,
tagName: string,
): Element[];
/**
* Like `scryRenderedDOMComponentsWithTag()` but expects there to be one result,
* and returns that one result, or throws exception if there is any other
* number of matches besides one.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function findRenderedDOMComponentWithTag(
root: Component<any>,
tagName: string,
): Element;
/**
* Finds all instances of components with type equal to `componentClass`.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function scryRenderedComponentsWithType<T extends Component<any>, C extends ComponentClass<any>>(
root: Component<any>,
type: ClassType<any, T, C>,
): T[];
/**
* Same as `scryRenderedComponentsWithType()` but expects there to be one result
* and returns that one result, or throws exception if there is any other
* number of matches besides one.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function findRenderedComponentWithType<T extends Component<any>, C extends ComponentClass<any>>(
root: Component<any>,
type: ClassType<any, T, C>,
): T;
/**
* Call this in your tests to create a shallow renderer.
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function createRenderer(): ShallowRenderer;
// NOTES
// - the order of these signatures matters - typescript will check the signatures in source order.
// If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
// `strictNullChecks: false`.
// - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
declare const UNDEFINED_VOID_ONLY: unique symbol;
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
/**
* 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 callback A synchronous, void callback that will execute as a single, complete React commit.
*
* @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
*
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
// While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules.
export function act(callback: () => VoidOrUndefinedOnly): void;
/**
* @deprecated https://react.dev/warnings/react-dom-test-utils
*/
export function act<T>(callback: () => T | Promise<T>): Promise<T>;
// Intentionally doesn't extend PromiseLike<never>.
// Ideally this should be as hard to accidentally use as possible.
export interface DebugPromiseLike {
// the actual then() in here is 0-ary, but that doesn't count as a PromiseLike.
then(onfulfilled: (value: never) => never, onrejected: (reason: never) => never): never;
}
* @deprecated Import `act` from `react` instead.
*/ act,
} from "react";
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc