Thread
j
6mo ago
React Native Expo - Android simulator does not get riveRef in useEffect
When testing riveRef in useEffect iOS gets the
useEffect(() => { console.log(`${Platform.OS} riveRef.current: `, riveRef.current); }, [riveRef.current]);
In iOS simulator this will log `null` first and than immediately a rive object:
ios riveRef.current: null ios riveRef.current: {"fireState": [Function anonymous], "fireStateAtPath": [Function anonymous], "pause": [Function anonymous], "play": [Function anonymous], "reset": [Function anonymous], "setInputState": [Function anonymous], "setInputStateAtPath": [Function anonymous], "setTextRunValue": [Function anonymous], "stop": [Function anonymous], "touchBegan": [Function anonymous], "touchEnded": [Function anonymous]}
But in android it never gets the rive object and logs only `null`
android riveRef.current: null
How can I access riveRef object in useEffect for android?
2 replies
j
6mo ago
That sounds like it should work. Can you send the full code you're using for that component? Also, can you verify that you're using the latest version of rive-react-native and confirm the simulator OS version?
j
Author
6mo ago
Ok I figured it out. The issue was that Rive component was not initialized because I was fecthing data and than initializing the component so the useEffect where I needed to use riveRef.current method never got the riveRef object.
This is not Rive related at all.