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
get static rootInstance(): any;Defined in: src/betterdiscord/api/reactutils.ts:137
Deprecated
Returns
any
Methods
getInternalInstance()
static getInternalInstance(node: HTMLElement): Fiber | null;Defined in: src/betterdiscord/api/reactutils.ts:147
Gets the internal React data of a specified node.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | HTMLElement | Node to get the internal React data from |
Returns
Fiber | null
Either the found data or undefined
getOwnerInstance()
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
| Parameter | Type | Description |
|---|---|---|
node | | HTMLElement | undefined | Node to obtain React instance of |
options | GetOwnerInstanceOptions | Options for the search |
Returns
object | null | undefined
The owner instance or undefined if not found
getType()
static getType<T>(elementType: ElementType<T>): T;Defined in: src/betterdiscord/api/reactutils.ts:291
Type Parameters
| Type Parameter |
|---|
T extends FC<{ }> |
Parameters
| Parameter | Type |
|---|---|
elementType | ElementType<T> |
Returns
T
wrapElement()
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
| Parameter | Type | Description |
|---|---|---|
element | | HTMLElement | HTMLElement[] | Element or array of elements to wrap |
Returns
typeof ReactWrapper
Unrendered React component
wrapInHooks()
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
| Parameter | Type |
|---|---|
functionComponent | | T | ForwardRefExoticComponent<T> | MemoExoticComponent<T | ForwardRefExoticComponent<T>> |
customPatches | Partial<PatchedReactHooks> |
Returns
(props: ComponentProps<T>):
| string
| number
| bigint
| boolean
| ReactElement<unknown, string | JSXElementConstructor<any>>
| Iterable<ReactNode, any, any>
| Promise<ReactNode>
| null
| undefined;Parameters
| Parameter | Type |
|---|---|
props | ComponentProps<T> |
Returns
| string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | Promise<ReactNode> | null | undefined