1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-23 15:14:23 +00:00
festa/hooks/useStateContext.tsx

13 lines
511 B
TypeScript
Raw Normal View History

2022-05-24 16:55:21 +00:00
import * as React from "react"
import { useContext } from "react"
import { createDefinedContext } from "./useDefinedContext"
/**
* 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>>]>()
}