cread custom splash / launch screen using an animated svg - react-native

I am trying to add an animated SVG as an application loader in a React native app. Their docs don't offer any solution on how I could approach this.

Back when I was working on a react native project, we had used a simple method to achieve splash screen effect.
We had called setTimeout() in componentDidMount() to navigate to the home-screen after 2 seconds. Also, we used to check whether the user is logged-in. If so, we'd navigate straight to the home screen skipping the annoying splash screen altogether.

Related

React navigation modals on react native web - Prevent url path update

I have a react native app that we are implementing the react native web version using: React native web, the app uses the latests react native navigation library.
So far, mostly everything is working except for modals, the problem that i have is that when i open a modal, the URL path on web updates (I.E: from /signup if i open a modal it switch to /legalAgreementModal?QUERY_PARAMS....), so if i refresh the page the modal works but i can't close the modal anymore. I thought about adding a conditional on the modal to goBack if there is anything to go back to, but the problem is that i have too many modals that can go back to different screens so it will be a huge change if i have to add that logic to every modal.
My question is, is there a way to avoid modals to update my path? So if user refresh they lost the modal but they are on the original screen? Perhaps another workaround that you guys may know could help also!.
Thanks!
I tried adding a conditional on modal close action, adding empty string as the modal path.

Lottie Splash Screen with Expo - animated splash screen with Expo

I am looking for a way to create an animated Splash Screen in React Native project using Expo.
I found Lottie as a solution, but the only info I can get about it is about the animations within the app itself - is there ANY possible solution that would allow a creation of an animated splash screen with Expo? For now, I have only a static png file.
There is an example provided in the Expo docs here:
https://github.com/expo/examples/tree/master/with-splash-screen
Although it's technically not an animated splash screen, but a way to automatically hide the static splash screen (which would be the first frame of your animation) and then immediately switch to playing the animation once the app is loaded. I'm doing it this way and it works well enough.
This NPM module seems to work in a similar fashion so maybe you could use that
https://www.npmjs.com/package/react-native-animated-splash-screen
But it's still not a native animated splash screen which I don't think is possible using even vanilla React Native let alone Expo.
Here I am using this module for custom animated splash screen using expo react native project. I hope it will work for you too.
Here is the module link: click here
Let me know if you need any other help.

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 play an intro animation on splash screen with react native expo?

Currently, if I add a .gif to app.json, it does not work
"splash": {
"image": "./assets/splash.gif"
}
Edit: It looks like, they are currently working on it, here: (https://expo.canny.io/feature-requests/p/improved-splash-screen-api).
I see you are trying to use gif for the splash screen. Well I have a bad news. Splash screen API of native platform (iOS & Android) doesn't support gif, infact they only support 'png' images.
But, the good news is there is a work around.
We had a similar requirement in our project so we created our custom AppLoading (Provided by Expo) component which has a face of our gif image and in the background it works similar to AppLoading i.e. fetch data and caching. We used a static png image for default splash screen and the transition between static image to gif worked for us.
This is the simplest way but has a drawback that between the static splash screen and animated there is white screen visible for a short duration of time.
It happens due to the fact that your javascript bundle is being downloaded in the background and until and unless your entire JS doesn't load you will see a white screen.
To overcome this you need to detach your expo app as we will be doing some native changes.
Install and follow the instruction in this module.
Benefit of this module is that it exposes the 'hide' function in the javascript.
Basic flow of App.
App loading start => Static splash screen visible
Screen is visible till our javascript bundle is not loaded
Bundle loads => call hide function exposed by modules on ComponentDidMount of SplashScreen component
Static Splash screen hides => Animated splash screen is visible with background task working (caching and API call)
Further App Flow
If you're talking about the launch screen and you're not using create-react-native-app you'll have to edit the native launch screen per platform to use your animation.
If you're using create-react-native-app with Expo then you could look at the Splash Screen API.
Expo since version 29 supports animated SVG and GIF. It also provides an API to generate your own splash screens without AppLoading.
Please check: https://docs.expo.io/versions/v29.0.0/sdk/splash-screen#example-without-apploading
Expo team has completed: "Improved Splash Screen API" ticket. So now, you can do it as explained in their docs: https://docs.expo.io/versions/v29.0.0/sdk/splash-screen/!

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