Problem is that it's not "React", but rather "React-Native". There's no such thing as an ID referencing an HTML element.. Actually, I initially thought that myString
would reference the GLView element, which would in turn act as a div
. I tried another approach
const Character = () => {
useEffect(() => {
new spine.SpinePlayer("test-id", {
jsonUrl: "assets/spine/spineboy-pro.json",
atlasUrl: "assets/spine/spineboy-pro.atlas",
animation: "walk",
showControls: false,
premultipliedAlpha: true,
backgroundColor: "#cccccc",
alpha: true,
preserveDrawingBuffer: true,
defaultMix: 1,
controlBones: ["root"],
viewport: {
debugRender: true,
},
});
}, []);
return (
<View nativeID="test-id">
</View>
);
};
export default Character;
But I get the following : undefined is not an object (evaluating 'new _spinePlayer.default.SpinePlayer')
Actually I just read the source code for SpinePlayer and it uses the document variable, which doesn't exist in react-native, since it's made to build on mobile devices, not a web page. However, I see that a library exists for Flutter, which is also for mobile development.. So I guess there's a way to make this work for react-native.. ?