wip: migrate frontend to new backend
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { PropsWithChildren, createContext, useEffect, useMemo } from "react";
|
||||
import { PropsWithChildren, createContext, useContext, useMemo } from "react";
|
||||
import { Ark } from "./ark";
|
||||
|
||||
export const ArkContext = createContext<Ark>(undefined);
|
||||
@@ -7,3 +7,11 @@ export const ArkProvider = ({ children }: PropsWithChildren<object>) => {
|
||||
const ark = useMemo(() => new Ark(), []);
|
||||
return <ArkContext.Provider value={ark}>{children}</ArkContext.Provider>;
|
||||
};
|
||||
|
||||
export const useArk = () => {
|
||||
const context = useContext(ArkContext);
|
||||
if (context === undefined) {
|
||||
throw new Error("Ark Provider is not import");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user