React Wasm Versions Save

Declarative WebAssembly instantiation for React

1.0.1

5 years ago

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

0.2.0

5 years ago

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

0.1.2

5 years ago