W
W
Webber2021-12-28 09:54:48
React Native
Webber, 2021-12-28 09:54:48

How to make a global timer?

I use @react-navigation/native-stackand for navigation @react-navigation/bottom-tabs.

const StackNav = createNativeStackNavigator();
const BottomTab = createBottomTabNavigator();


BookCatalog:
->Books: (timer)
-> ->Book (timer)
Settings:
Help:

Task : make a timer (stopwatch) that starts when you click on the button and is shown on the pages (Books, Book).

When switching between pages in StackNav, the components are always re-rendered and the timer is reset, in BottomTab the state is saved. How to make it so that there is no re-rendering on StackNav - I did not find an answer.
It is not very clear how to store in redux.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Makarov, 2022-01-17
@kirbi1996

Throw in asyncstorage, or as a reasonable option, this is the State Manager

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question