onPointSelected is very slow when I update a state
Hi,
I tried to update a state in my component, thanks to onPointSelected props, but when I swipe my finger on the line, the pointer is very very slow to update.
I guess it is because I set a state at each time setFingerX is called
Do you have an idea how to update my state ?
const [selectedGraphPoint, setSelectedGraphPoint] = useState<GraphPoint>({
value: 0,
date: new Date(),
});
return (<>
<TotalAmountCard amount={selectedGraphPoint.value} />
<LineGraph
points={points}
color={theme.colors.base.text.secondary}
style={styles.graphContainer}
enablePanGesture
animated
onPointSelected={setSelectedGraphPoint}
/>
</>)
Hello, I had the same issue, please check this https://github.com/margelo/react-native-graph/issues/8 Long story short you need to move your state to animated values
Hello, I had the same issue, please check this #8 Long story short you need to move your state to animated values
Yes, @DDushkin is right.
The onPointSelected callback will run on every change of the AnimatedValue driving the graph.
So any changes triggered by that callback, will have to be run on the UI thread...
Will close this, as this should be fixed.
Feel free to open a new issue, if you still have any issues