2022-06-08 02:55:16 +00:00
|
|
|
import { Context, Dispatch, SetStateAction } from "react"
|
2022-05-27 00:46:30 +00:00
|
|
|
import { createDefinedContext } from "./definedContext"
|
2022-05-24 16:55:21 +00:00
|
|
|
|
|
|
|
/**
|
2022-06-08 02:55:16 +00:00
|
|
|
* Create a new defined context (see {@link createDefinedContext}) containing the tuple returned by useState for the given type.
|
2022-05-24 16:55:21 +00:00
|
|
|
*
|
|
|
|
* @returns The created context.
|
|
|
|
*/
|
2022-06-08 02:55:16 +00:00
|
|
|
export function createStateContext<T>(): Context<[T, Dispatch<SetStateAction<T>>] | undefined> {
|
2022-05-24 16:55:21 +00:00
|
|
|
return createDefinedContext<[T, React.Dispatch<React.SetStateAction<T>>]>()
|
|
|
|
}
|