@webwasm/numjs-react
v0.1.0
Published
React hooks and provider for @webwasm/numjs-core — use NumPy-style WebAssembly arrays in your React app.
Downloads
66
Maintainers
Readme
@webwasm/numjs-react
React hooks and provider for
@webwasm/numjs-core— use NumPy-style WebAssembly arrays in your React app.
npm install @webwasm/numjs-core @webwasm/numjs-reactimport { NpProvider, useNp } from '@webwasm/numjs-react';
function App() {
return (
<NpProvider fallback={<p>Loading WASM…</p>}>
<Matrix />
</NpProvider>
);
}
function Matrix() {
const { np, ready } = useNp();
if (!ready) return null;
const a = np.arange(9);
return <pre>{JSON.stringify(np.toArray(a))}</pre>;
}API
<NpProvider fallback={…}>— initialises WASM on mount and provides thenpnamespace via contextuseNp()→{ np, ready, error }— accessnpand loading state from any child component
Full docs and examples: https://github.com/eklavya-raj/numjs
