1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-10-16 15:07:27 +00:00
festa/utils/stateContext.ts
2022-05-28 05:45:05 +02:00

12 lines
508 B
TypeScript

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