Calling the WebAssembly API in an HTML file works perfectly,
<html>
<body>
<script>
...
WebAssembly.instantiate(bytes, importObject)
...
</script>
</body>
</html>
However, calling it in a React Component, when running 'npm start' at the root of my react-app, results in this error:
'WebAssembly' is not defined no-undef
import React from 'react';
export default class WasmContainer extends React.Component {
constructor(props) {
super(props);
this.func = this.func.bind(this);
}
func(){
...
WebAssembly.instantiate(bytes, importObject)
...
return "...";
}
render() {
return (<p>{this.func()}</p>)
}
}
I want to run a .wasm file from a React Component and this is blocking me.
How to solve this problem?
WebAssemblyin your React component is not definedimport WebAssembly from 'web-assembly'