UNPKG

r3bl-ts-utils

Version:

The `r3bl-ts-utils` package is a set of useful TypeScript functions and classes that can be used in Node.js and browser environments. They are inspired by Kotlin stdlib, and Rust to write code as expressions rather than statements, colorized text, powerfu

25 lines (24 loc) 1.26 kB
import * as React from "react"; import { Dispatch, SetStateAction } from "react"; export declare type SetState<T> = Dispatch<SetStateAction<T>>; export declare type StateHook<T> = [T, SetState<T>]; export declare class StateHolder<T> { readonly value: T; readonly setValue: SetState<T>; constructor(value: T, setValue: SetState<T>); static createFromArray<T>(stateHook: StateHook<T>): StateHolder<T>; asArray: () => StateHook<T>; toString: () => string; } export declare type ReactRef<T> = React.MutableRefObject<T | undefined>; export declare type ReactRefReceiverFn<T> = (it: T) => void; /** * @param refObject its `current` property is value of `it` * @param receiverFn lambda that accepts `it`; only runs if `refObject.current` property is truthy * @return refObject return the refObject that is passed */ export declare const _withRef: <T>(refObject: ReactRef<T>, receiverFn: ReactRefReceiverFn<T>) => ReactRef<T>; export declare function useForceUpdateFn(): () => void; export declare const emptyArray: () => JSX.Element[]; export declare type RenderItemFn<T> = (input: T, index: number) => JSX.Element; export declare const makeReactElementFromArray: <T>(inputsArray: T[], itemRendererFn: RenderItemFn<T>) => JSX.Element;