Dynamically render Skia elements from a SharedValue<[]>? #2495
Unanswered
davidjosefson
asked this question in
Q&A
Replies: 1 comment
-
you probably want to use an offscreen surface for that or a picture: https://shopify.github.io/react-native-skia/docs/shapes/pictures/ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm stuck with an issue that I've struggling with for the past two days, which is how to render Skia elements dynamically based on items inside a SharedValue<Object[]>.
The effect I'm after is that when panning inside a chart the number of rows in my legend should instantly be updated with the corresponding y-values.
I'm using victory-native, react-native-reanimated and react-native-skia. I get a "chart press state" from victory which is defined like this:
So I basically get an object that looks like this:
I need to filter this data for non-unique and empty values everytime it updates, which I can do successfully inside a useDerivedValue(), like this:
uniqueValues
is now aReadonly<SharedValue<{value: SharedValue<number>, position: SharedValue<number>}[]>>
Is it possible to somehow map over this SharedValue-array and render one Skia
<Text>
per item dynamically - all on the UI thread?Or is there any other Skia element that is better suited for this kind of task?
As long as I keep the original data structure without filtering (an array of SharedValues) its no biggie to render the legend - but I have to filter the values before using them. Is it possible to somehow get an array of SharedValues from useDerivedValues() instead of an array inside a SharedValue?
Beta Was this translation helpful? Give feedback.
All reactions