create-custom-context
Version:
A React Context hook factory that enables using React hooks within context value functions. Perfect for game development, state management, and complex interactive applications with TypeScript support.
3 lines (2 loc) • 339 B
JavaScript
"use client"
import{createContext as u,use as C}from"react";import{jsx as c}from"react/jsx-runtime";var i=(o,n)=>{let t=u(n);return[({children:e})=>{let r=o();return c(t.Provider,{value:r,children:e})},()=>{let e=C(t);if(e===void 0)throw new Error("useContext must be used within a Provider");return e}]};export{i as createCustomContext};