'How to change state without re-rendering in react native

I am making an app which is calling an API repeatedly and changing state, and I have another function which is listening to an event and update some state but I want to update it without re-rendering because it causes some unwanted behaviour to chain of repeatedly API calling,

Any help will be appreciated.



Solution 1:[1]

If you want to store some data without triggering rerender, use useRef() hook for this instead of useState.

Solution 2:[2]

The problem solved by removing the function call depend on state.

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 Wraithy
Solution 2 Demo In