mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-24 11:01:17 -08:00
11 lines
374 B
TypeScript
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));
|
|
}
|