react
Some helpers for dealing with React.
// access like this (preferred)
import {useForceUpdate} from "@liqvid/utils/react";
// or like this (legacy)
import {Utils} from "liqvid";
const {useForceUpdate} = Utils.react;
combineRefs()
Combine multiple refs into one. Parameters:
Parameters
...args: React.Ref[]
Refs to combine.
Return value
Returns a ref which applies all the passed refs.
combineRefs<T>(...args: React.Ref<T>[]): (ref: T) => void
recursiveMap()
Recursive version of React.Children.map
. Used internally by IdMap and some integrations; you probably don't need it.
recursiveMap
(children: React.ReactNode, fn: (child: React.ReactElement<any>) => React.ReactElement<any>)
: React.ReactChild[];
useForceUpdate()
A forceUpdate()
function.
useForceUpdate(): React.DispatchWithoutAction;
usePromise()
Returns an array [promise, resolve, reject]
where promise
is a Promise, resolve
is a function to resolve promise
, and reject
is a function to reject promise
.
usePromise(): [Promise, resolve: () => void, reject: () => void];