[英]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.
但是当我将滑块与 victort 图表一起使用时,滑块会滞后,并且状态值的变化很晚才反映在屏幕上。
To see full details with screenshot\/GIF click here<\/a>要查看带有屏幕截图\/GIF 的完整详细信息,
请单击此处<\/a>
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 . 这是由于您使用
onChange
将值发送到状态时拖动的事实, 这将导致每次重新渲染 。
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: 这可以通过两种方式解决:
componentShouldUpdate()
lifecycle callback componentShouldUpdate()
生命周期回调的子组件中的更新 onSlidingComplete
props instead of onChange
prop onSlidingComplete
道具而不是onChange
道具中更新状态 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
我没有尝试,但我想知道它是否有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.