parent
2a756e152d
commit
6d150f75f8
1 changed files with 29 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||||||
|
import { createContext, useState, ReactNode } from 'react'; |
||||||
|
|
||||||
|
interface AnvilContextType { |
||||||
|
uuid: string; |
||||||
|
setAnvilUuid: (uuid: string) => void; |
||||||
|
} |
||||||
|
|
||||||
|
const AnvilContextDefault: AnvilContextType = { |
||||||
|
uuid: '', |
||||||
|
setAnvilUuid: () => null, |
||||||
|
}; |
||||||
|
|
||||||
|
const AnvilContext = createContext<AnvilContextType>(AnvilContextDefault); |
||||||
|
|
||||||
|
const AnvilProvider = ({ children }: { children: ReactNode }): JSX.Element => { |
||||||
|
const [uuid, setUuid] = useState<string>(''); |
||||||
|
const setAnvilUuid = (anvilUuid: string): void => { |
||||||
|
setUuid(anvilUuid); |
||||||
|
}; |
||||||
|
|
||||||
|
return ( |
||||||
|
<AnvilContext.Provider value={{ uuid, setAnvilUuid }}> |
||||||
|
{children} |
||||||
|
</AnvilContext.Provider> |
||||||
|
); |
||||||
|
}; |
||||||
|
|
||||||
|
export default AnvilProvider; |
||||||
|
export { AnvilContext }; |
Loading…
Reference in new issue