-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Labels
Description
Let's say there's no network connection while loading rive.wasm, how do I able to know there's an error loading wasm?
window.onerror = () => {
// won't catch wasm loading error
}
window.onunhandledrejection = () => {
// won't catch wasm loading error
}
const loadingRiveFile = (async () => {
const file = new RiveFile({ src: '...' })
try {
await file.init()
} catch {
// won't catch wasm loading error
}
return file
})()
function MyComponent() {
const riveFile = use(loadingRiveFile)
const { RiveComponent } = useRive({
riveFile,
onLoadError: () => {
// won't catch wasm loading error
}
})
return (
// ...
)
}
function App() {
return (
<Suspense fallback={'loading...'}>
<MyComponent />
</Suspense>
)
}