f089f45781
Co-authored-by: Dan Abramov <dan.abramov@gmail.com> Co-authored-by: Paul Frazee <pfrazee@gmail.com> Co-authored-by: Eric Bailey <git@esb.lol> Co-authored-by: Samuel Newman <mozzius@protonmail.com>
26 lines
743 B
TypeScript
26 lines
743 B
TypeScript
import React from 'react'
|
|
|
|
type StateContext =
|
|
| {
|
|
uri: string
|
|
isClip?: boolean
|
|
}
|
|
| undefined
|
|
type SetContext = (v: StateContext) => void
|
|
|
|
const stateContext = React.createContext<StateContext>(undefined)
|
|
const setContext = React.createContext<SetContext>((_: StateContext) => {})
|
|
|
|
export function Provider({children}: {children: React.ReactNode}) {
|
|
const [state, setState] = React.useState<StateContext>()
|
|
|
|
return (
|
|
<stateContext.Provider value={state}>
|
|
<setContext.Provider value={setState}>{children}</setContext.Provider>
|
|
</stateContext.Provider>
|
|
)
|
|
}
|
|
|
|
export const useActiveStarterPack = () => React.useContext(stateContext)
|
|
export const useSetActiveStarterPack = () => React.useContext(setContext)
|