Run react-native info in your project and share the content.
System:
OS: macOS 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
Memory: 28.46 MB / 8.00 GB
Shell: 2.7.1 - /usr/local/bin/fish
Binaries:
Node: 9.4.0 - /usr/local/bin/node
npm: 5.6.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
Android SDK:
API Levels: 22, 25, 26, 27, 28, 29
Build Tools: 23.0.3, 25.0.0, 26.0.2, 27.0.3, 28.0.2, 28.0.3, 29.0.0
System Images: android-22 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.5 => 0.60.5
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-rename: 2.2.
What react-native-splash-screen version are you using?
"react-native-splash-screen": "^3.2.0",
What platform does your issue occur on? (Android/iOS/Both)
iOS only, Android is functioning.
Describe your issue as precisely as possible :
1) Steps to reproduce the issue or to explain in which case you get the issue
On opening app and splash screen it gets stuck and do not seem to respond to the SplashScreen.hide(); command in react-native.
2) Interesting logs
Join a screenshot or video of the problem on the simulator or device?
Show us the code you are using?
iOS
@implementation AppDelegate
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"AppName"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[RNSplashScreen show];
return YES;
}
@end
React-Native
import React, { Component } from 'react';
import SplashScreen from 'react-native-splash-screen'
class SignIn extends Component {
componentDidMount(){
SplashScreen.hide();
}
....
}
Figured it out, it was due to an error with asyncstorage which I didnt see before finding this function
componentDidCatch() {
SplashScreen.hide();
}
Guess this causes many to raise issues with splashscreen when not really seeing the actual error. componentDidCatch helped me a lot anyway.
@gudbrand3 is there any issues with using this lib with async methods? I've also go an async method after which I have to hide the splash screen. the console logs don't indicate any issues, and my async methods also work correctly, but the splash screen doesn't hide. It also seems specific to iOS only. Any pointers?
@ShaharyarMaroof same issue. RN 0.60.5 and iOS 12.4
@ShaharyarMaroof was you able to solve this issue?
@EJohnF I kind of found a work around for this. I wrapped my initial async call in setTimeout so that it can be triggered after a small delay. Other than that I couldn't find any solution.
I'm not 100% on this issue but my findings are like this:
You cannot use SplashScreen.hide() inside an async function (which i assume a lot of us are)
You can verify this by commenting out the async code and making your componentDidMount or onBeforeLift (in my case) not an async function.
It appears to work, however, if you await SplashScreen.hide()!
I haven't verified this after making a build yet though so will update later on...
Most helpful comment
@gudbrand3 is there any issues with using this lib with async methods? I've also go an async method after which I have to hide the splash screen. the console logs don't indicate any issues, and my async methods also work correctly, but the splash screen doesn't hide. It also seems specific to iOS only. Any pointers?