deno.land / x / nano_jsx@v0.1.0 / context.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
export const createContext = (ctx: any) => { let _ctx = ctx return { Provider: (props: any) => { if (props.value) _ctx = props.value return props.children }, Consumer: (props: any) => { return { component: props.children[0](_ctx), props: { ...props, context: _ctx } } }, get: () => _ctx, set: (ctx: any) => (_ctx = ctx) }}
export const useContext = (ctx: any) => { const _ctx = ctx if (_ctx && typeof _ctx.get === 'function') { return _ctx.get() }}
nano_jsx

Version Info

Tagged at
8 months ago