Skip to content

Class: ReactUtils

Defined in: src/betterdiscord/api/reactutils.ts:133

ReactUtils is a utility class for interacting with React internals. Instance is accessible through the BdApi. This is extremely useful for interacting with the internals of the UI.

Accessors

rootInstance

Get Signature

ts
get static rootInstance(): any;

Defined in: src/betterdiscord/api/reactutils.ts:137

Deprecated
Returns

any

Methods

getInternalInstance()

ts
static getInternalInstance(node: HTMLElement): Fiber | null;

Defined in: src/betterdiscord/api/reactutils.ts:147

Gets the internal React data of a specified node.

Parameters

ParameterTypeDescription
nodeHTMLElementNode to get the internal React data from

Returns

Fiber | null

Either the found data or undefined


getOwnerInstance()

ts
static getOwnerInstance(node: 
  | HTMLElement
  | undefined, options: GetOwnerInstanceOptions): object | null | undefined;

Defined in: src/betterdiscord/api/reactutils.ts:165

Attempts to find the "owner" node to the current node. This is generally a node with a stateNode - a class component.

Parameters

ParameterTypeDescription
node| HTMLElement | undefinedNode to obtain React instance of
optionsGetOwnerInstanceOptionsOptions for the search

Returns

object | null | undefined

The owner instance or undefined if not found


getType()

ts
static getType<T>(elementType: ElementType<T>): T;

Defined in: src/betterdiscord/api/reactutils.ts:291

Type Parameters

Type Parameter
T extends FC<{ }>

Parameters

ParameterType
elementTypeElementType<T>

Returns

T


wrapElement()

ts
static wrapElement(element: 
  | HTMLElement
  | HTMLElement[]): typeof ReactWrapper;

Defined in: src/betterdiscord/api/reactutils.ts:203

Creates an unrendered React component that wraps HTML elements.

Parameters

ParameterTypeDescription
element| HTMLElement | HTMLElement[]Element or array of elements to wrap

Returns

typeof ReactWrapper

Unrendered React component


wrapInHooks()

ts
static wrapInHooks<T>(functionComponent: 
  | T
  | ForwardRefExoticComponent<T>
  | MemoExoticComponent<T | ForwardRefExoticComponent<T>>, customPatches: Partial<PatchedReactHooks>): (props: ComponentProps<T>) => 
  | string
  | number
  | bigint
  | boolean
  | ReactElement<unknown, string | JSXElementConstructor<any>>
  | Iterable<ReactNode, any, any>
  | Promise<ReactNode>
  | null
  | undefined;

Defined in: src/betterdiscord/api/reactutils.ts:239

Type Parameters

Type Parameter
T extends FC<{ }>

Parameters

ParameterType
functionComponent| T | ForwardRefExoticComponent<T> | MemoExoticComponent<T | ForwardRefExoticComponent<T>>
customPatchesPartial<PatchedReactHooks>

Returns

ts
(props: ComponentProps<T>): 
  | string
  | number
  | bigint
  | boolean
  | ReactElement<unknown, string | JSXElementConstructor<any>>
  | Iterable<ReactNode, any, any>
  | Promise<ReactNode>
  | null
  | undefined;
Parameters
ParameterType
propsComponentProps<T>
Returns

| string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | Promise<ReactNode> | null | undefined