react-native-skia: ReferenceError: Can't find variable: SkiaApi In Expo
I tried to use the simple example from here https://shopify.github.io/react-native-skia/docs/paint/overview in react native expo
// code
import {Canvas, Circle, Paint, Group} from "@shopify/react-native-skia";
export default function App() {
const r = 128;
return (
<Canvas style={{ flex: 1 }}>
<Paint color="lightblue" />
<Circle cx={r} cy={r} r={r} />
{/* The paint is inherited by the following sibling and descendants. */}
<Group style="stroke" strokeWidth={10}>
<Circle cx={3 * r} cy={3 * r} r={r} />
</Group>
</Canvas>
);
}
i’m getting the following error
ReferenceError: Can't find variable: SkiaApi
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:172:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/@react-native/polyfills/error-guard.js:49:36 in ErrorUtils.reportFatalError
at node_modules/metro-runtime/src/polyfills/require.js:204:6 in guardedLoadModule
at http://127.0.0.1:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:169518:3 in global code
here is my package.json dependencies
"dependencies": {
"@shopify/react-native-skia": "https://github.com/Shopify/react-native-skia/releases/download/v0.1.64-alpha/shopify-react-native-skia-0.1.64.tgz",
"expo": "~44.0.0",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-gesture-handler": "^2.1.1",
"react-native-reanimated": "^2.3.1",
"react-native-web": "0.17.1"
},
Please help and thanks for the great work!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 42 (8 by maintainers)
Commits related to this issue
- [dev-launcher][dev-menu] fix `RCTBridge.currentBridge` to be override (#17780) # Why some third party libraries would use `[RCTBridge currentBridge]` to access the bridge instance. because dev-men... — committed to expo/expo by Kudo 2 years ago
- [dev-launcher][dev-menu] fix `RCTBridge.currentBridge` to be override (#17780) # Why some third party libraries would use `[RCTBridge currentBridge]` to access the bridge instance. because dev-men... — committed to expo/expo by Kudo 2 years ago
in the next version of expo-dev-client with the fix, the problem should be solved. we are still recommending use some alternative way to get the bridge other than
RCTBridge.currentBridge
because it doesn’t well support multiple bridge@kevinmcalear Yes, I’m sorry for the previous comment, it did in fact came back the same way you encountered it.
So maybe it only happens with expo-dev-clients and not with expo go. @Kudo could this be a clue?
I’ve been working days with SDK 49 and Skia and didn’t have the issue once. I will close it for now but please let’s reopen it if it’s still happening for some people with hopefully information on how to reproduce it.
@wcandillon expo-dev-clients needs to be rebuild when react-native-skia dependancies are upgraded (like react-native, expo-dev-client). Can confirm I ran expo-doctor which updates dependancies and had the issue. I rebuilt my my development client and everything works fine.
This is fixed part of the latest version of the dev client.
Thanks so much for the input and explanation again! 😃 Really appreciate it. For reference you can paste the link to the issue in the expo-dev-client if possible for tracking.
@Jonatthu we’re having the exact same issue as well, hopefully we can fix it soon.