简体   繁体   中英

when including victory chart react-native slider becomes laggy and state value change is reflecting lately

The problem is that when I just use a slider only with no Victory chart in the application only just implementing the slider then there is no problem in the slider. But when I use the slider along with the victort chart then the slider is laggy and the state value change is reflecting on screen very late.

this is due to the fact that you are sending values to the state as dragging with onChange , and this will cause a re-render every time .

If you render few things nothing happens , but when the render is more heavy this get more noticeable.

This can be fixed in 2 way:

  • Manage update in child components implementing componentShouldUpdate() lifecycle callback
  • Simply update the state in onSlidingComplete props instead of onChange prop

Did you find the solution to this. Did you try to render the state in child component. I didn't try but I would like to know if it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM