mirror of
https://github.com/array-in-a-matrix/xinny.git
synced 2024-05-31 18:47:29 -04:00
10 lines
345 B
TypeScript
10 lines
345 B
TypeScript
|
import { Dispatch, ReactElement, SetStateAction, useState } from 'react';
|
||
|
|
||
|
type UseStateProviderProps<T> = {
|
||
|
initial: T | (() => T);
|
||
|
children: (value: T, setter: Dispatch<SetStateAction<T>>) => ReactElement;
|
||
|
};
|
||
|
export function UseStateProvider<T>({ initial, children }: UseStateProviderProps<T>) {
|
||
|
return children(...useState(initial));
|
||
|
}
|