Files
Sable/src/app/components/UseStateProvider.tsx
T
2026-05-01 04:59:25 +03:00

11 lines
374 B
TypeScript

import type { Dispatch, ReactElement, SetStateAction } from 'react';
import { 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));
}