Skip to content

Releases: mbasso/react-wasm

useWasm Hook

05 Mar 09:17
Compare
Choose a tag to compare

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

withWasm HoC

01 Feb 02:54
Compare
Choose a tag to compare

Features

Includes a new withWasm API that returns an HoC (thanks to @mfrachet in #1)

Fix

  • Fixes module reinstantiation using lifecycle methods (see #2)

Breaking changes

None

First release🎉

20 Jan 12:24
Compare
Choose a tag to compare