1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-10-16 06:57:26 +00:00
festa/utils/stateContext.ts

11 lines
430 B
TypeScript

import { Context, Dispatch, SetStateAction } from "react"
import { createDefinedContext } from "./definedContext"
/**
* Create a new defined context (see {@link createDefinedContext}) containing the tuple returned by useState for the given type.
*
* @returns The created context.
*/
export function createStateContext<T>(): Context<[T, Dispatch<T>] | undefined> {
return createDefinedContext<[T, React.Dispatch<T>]>()
}