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

Text component doesn't re-render on value change

gabimoncha opened this issue · comments

Description

Using a translate value (i.e. i18n) doesn't update the text component.
The Skia component is rendered before the translate value is retrieved, so the render box is empty.

Right now to make it work is by using x or y with useDerivedValue and putting the t(namespace) function in the dependency list.

const x = useDerivedValue(() => preX, [i18n.t('today')])

Version

0.1.241

Steps to reproduce

const preX = useSharedValue(0)
const x = useDerivedValue(() => preX.value, [t('today')])

...
<Text x={x} y={0} text={t('today')} color='white' font={font} />

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

Without useDerivedValue
Screenshot 2024-03-11 at 14 02 12

Wit useDerivedValue
Screenshot 2024-03-11 at 14 02 41

x.value won't rerender but x={x} will.

Can you confirm that there is no bug on our side here?

x.value won't rerender but x={x} will.

sorry, I copy pasted from my code, where I had x.value + 6

Could you share a small reproducible example?

yes, will do once I get a bit of time
I had to switch from i18n to react-i18next just to exclude a lib problem

I will close it for now but let's reopen it as soon as we have an example. Also we can add it to the example app at https://github.com/Shopify/react-native-skia/tree/main/example if there is an issue to be test there.