Shopify / react-native-skia

High-performance React Native Graphics using Skia

Home Page:https://shopify.github.io/react-native-skia

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dynamically updating the useSVG source crashes the app

JDBoots opened this issue · comments

Description

Hey guys!

We're having some issues working with the useSVG hook. When we dynamically update the source that we pass to useSVG, the app crashes.

A workaround would be to register multiple useSVG hooks for different use cases (which works), but that's maybe not ideal from a scalability viewpoint, we would prefer to only register one useSVG hook. Is that possible?

Thanks in advance, and congrats on the release of v1!

Version

1.0.2

Steps to reproduce

const [isOn, setIsOn] = useState(false);

const src1 = require('...')
const src2 = require('...')

const svg = useSVG(isOn ? src1 : src2);

Snack, code example, screenshot, or link to a repository

N/A

I will definitely investigate the crash but I strongly recommend you build you own data loading hook in the meantime.
We provide these data loading hook has simple helpers but we are seeing many clients having use-cases that goes beyond what these hook do.

But that being said, this does looks like an interesting issue to solve.

Hi @wcandillon, thanks for the incredibly fast response!

We'll see what we can do in the meantime in terms of data loading and I'll of course keep an eye out for new react-native-skia updates.

I couldn't reproduce the issue on iOS nor Android, let's reopen this if there are clear reproducible steps.