Skip to content

useWasm Hook

Latest
Compare
Choose a tag to compare
@mbasso mbasso released this 05 Mar 09:17
· 1 commit to master since this release

Features

add useWasm Hook πŸŽ‰

import { useWasm } from "react-wasm";

// supposing an "add.wasm" module that exports a single function "add"
const ExampleComponent = () => {
  const {
    loading,
    error,
    data
  } = useWasm({
    url: '/add.wasm'
  });

  if (loading) return "Loading...";
  if (error) return "An error has occurred";

  const { module, instance } = data;
  return <div>1 + 2 = {instance.exports.add(1, 2)}</div>;
};

Breaking changes

  • react-wasm now needs react@^16.8.0
  • dropped node@9 support