简体   繁体   English

当包括胜利图时,反应原生滑块变得迟钝并且状态值变化最近反映

[英]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: 这可以通过两种方式解决:

  • Manage update in child components implementing componentShouldUpdate() lifecycle callback 管理实现componentShouldUpdate()生命周期回调的子组件中的更新
  • Simply update the state in 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.

相关问题 React Native - 可触摸和胜利图表 - React Native - Touchable and Victory Chart 如何在javascript中更改对象状态值(react-native) - how to change object state value in javascript (react-native) React-Native 如何更改每个项目的 state 值? - React-Native How to change state value for each item? 重置为默认滑块值react-native - Reset to default slider value react-native 当使用布尔值更改状态时,React-native Redux组件不会重新呈现 - React-native Redux Component not re-rendering on state change with boolean value 当 redux 连接状态改变时,有状态的本机功能组件不会重新渲染 - Stateful react-native functional component don't re-render when redux connected state change 如何在 react-native 中修复我的延迟文本输入 - How can i fix my laggy textinput in react-native React-native,firestore:当实例变量改变其值时如何更新组件状态 - React-native, firestore: how to update component state when an instance variable changes its value React Native Selected item 未将状态反映到 UI - React Native Selected item is not reflecting the state to the UI 是否可以创建一个通过 react-native 中的 state 更改来实现的 promise? - Is it possible to create a promise that get fulfilled by a state change in react-native?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM