Closed iwater closed 1 year ago
Hi, I just tried to install the latest version of react-native-webassembly
as follows:
npx create-react-native-app -t with-typescript xxx
cd xxx
yarn add react-native-webassembly axios
npx expo prebuild
cd ios && pod install
cd ..
yarn ios
Then I loaded up some simple example inside App.tsx
:
import * as React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import * as WebAssembly from 'react-native-webassembly';
import axios from 'axios';
export default function App() {
React.useEffect(() => void (async () => {
try {
const {data} = await axios({
url: 'https://github.com/torch2424/wasm-by-example/raw/master/examples/hello-world/demo/assemblyscript/hello-world.wasm',
method: 'get',
responseType: 'arraybuffer',
});
const x = await WebAssembly.instantiate<{add: (a: number, b: number) => number}>(data);
console.warn(x.instance.exports.add(1000, 2000));
} catch (e) {
console.error(e);
}
})(), []);
return (
<View style={styles.container}>
<Text>Open up App.tsx to start working on your app!</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
This works as expected.
This may suggest a configuration issue with your project; the MutableMemoryHeaderBuffer
class in particular expects to be derived from React Native's MutableBuffer
.
It could be a couple of things:
0.71.1
).It could also be some other configuration issues, but these would be my bet.
I use 0.69.10 with hermes enable, when installed react-native-webassembly@0.3.2, build without error, so is react-native-webassembly@0.3.3 only support 0.71.1+ ?
I use 0.69.10 with hermes enable, when installed react-native-webassembly@0.3.2, build without error, so is react-native-webassembly@0.3.3 only support 0.71.1+ ?
Hey @iwater, sorry for the delay getting back to you. I believe this was one of those move-fast-break-things situations when we had basically zero users.
Hope you were able to make the upgrade and it wasn't too painful (but hey, it's React Native).