use-bsv-wasm
v0.0.5
Published
Hook for using bsv-wasm in react components.
Downloads
2
Readme
use-bsv-wasm
Hook for using bsv-wasm in react apps.
Usage
Import the useBsvWasm
hook
import { useBsvWasm } from "use-bsv-wasm";
Add to your AppContext:
import React, { ReactNode } from "react";
import { BsvWasmProvider } from "use-bsv-wasm";
interface Props {
children: ReactNode;
}
const AppContext: React.FC<Props> = ({ children }) => {
return <BsvWasmProvider>{children}</BsvWasmProvider>;
};
export default AppContext;
Use in your component.
import { useBsvWasm } from "use-bsv-wasm";
const { initialized } = useBsvWasm();
useEffect(() => {
if (initialialized) {
// Doesn't throw an error
const address = P2PKHAddress.from_string(
"1FVYXV4QnBv6XxqJZVjTb5HhXZV3z2kqjy"
);
}
}, [initialialized]);