'React Native: can calling setstate at least 10 times per second be slow for the app?
I use setState to be able to get the current duration of a video. But I was wondering if with setState, my application could be slow (because setState is called more than 10 times per second)? Knowing that setState is the parent component, and that it contains the video and several other components.
I know there is mobx, or redux. But for this kind of program, setState must be in the parent component for functional reasons...
So do you know if this might be a problem for my app performance ?
Solution 1:[1]
If it's re-rendering another components that shouldn't get re-rendered, yes this is a performance issue.
Also if you don't want to use an external state manager, you can simply use the React context API (https://beta.reactjs.org/learn/scaling-up-with-reducer-and-context).
Anyways, in order to fix performance, you may want to research about React.memo (https://www.w3schools.com/react/react_memo.asp).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Luka Cerrutti |
