How to check user is actively present or not in react native? - react-native

I want to check that user is active or not at application level.I have used PanResponder to detect user activity for one screen but I want to check for whole application in one component because I have more than 20 screens in application.
Note: I am using wix-react-native-navigation for navigation so every new screen is in navigation stack.

Related

React native container subpages navigation

I am creating a React native application with the following scenario:
There is a navigation bar at the bottom of the screen, allowing the user to navigate between three main pages. On one of these pages, there is a backdrop with a container overlayed on it with two buttons. Each of these buttons should show open different "pages" in that container, and the navigation bar will be hidden when the user opens one of those "pages". An image is included below.
App layout example
My question is: how is this best implemented in react native?
My original idea was to implement a custom Stack Navigator with createStackNavigator. While this does work, I was wondering if this is a good way to go about it.
One result from using a custom navigator is that the navigation state in the container is also bound to the back button of the device (on Android). However, this is a welcome feature in this case as it makes sense in the navigation flow.

react-navigation stack navigation without initial screen? (from a button)

We are using a different router for our app (react-router)
We are integrating react-navigation in some screens of our app.
(For example, we can adapt react-navigation for user profiles related screens)
Now, we have new requirements, where we want to use react-navigation from a button of an existing screen (which is not part of react-navigation)
Say you have a screen where there is a button which will create a new screen (stack a new screen). I want the navigation from the existing screen to new screen handled via react-navigation.

Why React native navigation loads all components at the same time?

I am using react native navigation v2 by wix. I have a welcome screen with login screen and register. I start the startAuth.js from App.js. There are two tabs with login and register.
But as soon as app starts the componentWillMount methods runs in the register screen but yet i am at login tab.
Why is this happening?
react-native-navigation's Tab does not support lazy loading. But there are two special lifecyle functions where you can put your logic when component appear or disappear on screen
componentDidAppear(): called each time this component appears on screen
componentDidDisappear(): called each time this component disappears from screen
https://wix.github.io/react-native-navigation/docs/screen-lifecycle
There is also a discussion about topic https://github.com/wix/react-native-navigation/issues/1250

How to insert new scene on pop stack in react native?

I am working on existing react native project and I want to find solution for pop action on navigation stack where I want to introduce new scene which is actually not on stack.
I have three different type of route based on state of user logged In, logged out or in locked state. So while user's app state is locked at that time on launch I am directing user to reset account page from launch scene.
Launch Scene -> Reset Account
But on back event of Reset Account, I want to show login page instead of Launch scene, but Login scene is not in stack as of now.
So how to insert new scene when user performs pop action ?
I am new to react native and I don't know how to modify navigation stack programmatically without performing any animation ?
In my project there is one package named react-native-router-flux to handle react navigation.
Any insight will be helpful.
I suggest you create a SwitchNavigator between LaunchScreen and AccountStack
AccountStack is a StackNavigator that render both:
LoginScreen.
ResetAccountScreen. << This would be your initialRoute.

How can I show a splash screen in React Native with React Native Navigation while loading app Redux state?

I am trying to integrate React Native Navigation by Wix into my application and am not sure how to go about setting things up to handle a loading phase.
The library has a splash screen at the native layer but that is only displayed while the bundle is being parsed. Once that is complete and React Native takes over, I then rehydrate my Redux store (from Redux-Persist), make a couple checks, call out to an API to validate a token, and redirect the user to the proper screen. While all of this is happening, I want to display a loading screen but have no idea how to go about it using this library.
I don't want to show my app or let the user use the app until all of the loading and checks have completed.
Is this possible with this library? If so, how do I set it up? My navigation is tab based, no side drawer.
There're 2 options for you:
1. Call Navigation.startSingleApp with the only screen is "Loading Screen" when app start. At that time, you call rehydrate redux. When the call back invoked, you call Navigation.start (single or tab) to your main screen
2. Design the registerScreen with route "Loading" for loading screen. When app start, call Navigation.startSingleApp for the loading screen. On "componentDidMount" of loading screen, call rehydrate redux, when call back invoke, push to Main screen