webapp/gen/context/new/context.ejs.t

25 lines
802 B
Perl
Raw Normal View History

2023-02-10 09:40:44 +00:00
---
to: src/context/<%= h.changeCase.camel(name) %>.tsx
---
import type { Accessor, JSX } from 'solid-js'
import { createContext, createSignal, useContext } from 'solid-js'
type <%= h.changeCase.pascal(name) %>ContextType = {
2024-02-04 17:40:15 +00:00
2023-02-10 09:40:44 +00:00
}
const <%= h.changeCase.pascal(name) %>Context = createContext<<%= h.changeCase.pascal(name) %>ContextType>()
export function use<%= h.changeCase.pascal(name) %>() {
return useContext(<%= h.changeCase.pascal(name) %>Context)
}
export const <%= h.changeCase.pascal(name) %>Provider = (props: { children: JSX.Element }) => {
const actions = {
}
2024-02-04 17:40:15 +00:00
const value: <%= h.changeCase.pascal(name) %>ContextType = { ...actions }
2023-02-10 09:40:44 +00:00
return <<%= h.changeCase.pascal(name) %>Context.Provider value={value}>{props.children}</<%= h.changeCase.pascal(name) %>Context.Provider>
}