1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-23 07:04:22 +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>]>()
}