feat: upgrade to rust nostr 0.28
This commit is contained in:
@@ -1,28 +1,17 @@
|
||||
import {
|
||||
PropsWithChildren,
|
||||
createContext,
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
} from "react";
|
||||
import { PropsWithChildren, createContext, useContext, useMemo } from "react";
|
||||
import { Ark } from "./ark";
|
||||
|
||||
export const ArkContext = createContext<Ark>(undefined);
|
||||
|
||||
export const ArkProvider = ({ children }: PropsWithChildren<object>) => {
|
||||
const ark = useMemo(() => new Ark(), []);
|
||||
|
||||
useEffect(() => {
|
||||
if (ark) ark.load_account();
|
||||
}, []);
|
||||
|
||||
return <ArkContext.Provider value={ark}>{children}</ArkContext.Provider>;
|
||||
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;
|
||||
const context = useContext(ArkContext);
|
||||
if (context === undefined) {
|
||||
throw new Error("Ark Provider is not import");
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user