I have followed all the steps outlined in this guide: https://www.npmjs.com/package/react-native-splash-screen and also watched a YouTube tutorial covering the same process.
Here is the code snippet that I have implemented:
import * as React from 'react';
import SplashScreen from 'react-native-splash-screen';
import HomePage from './src/Home';
import {navigationRef} from './RootNavigation';
import * as RootNavigation from './RootNavigation.js';
const Stack = createStackNavigator();
export default class App extends React.Component {
componentDidMount() {
setTimeout(1000);
SplashScreen.hide();
}
render() {
return (
<NavigationContainer ref={navigationRef}>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={HomePage}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
}
Everything works fine except when I remove the componentDidMount method. The issue arises at the line where I call SplashScreen.hide();
The error message I encounter is:
TypeError: null is not an object (evaluating '_reactNativeSplashScreen.default.hide')
This error is located at:
in App (at renderApplication.js:45)
in RCTView (at AppContainer.js:109)
in RCTView (at AppContainer.js:135)
in AppContainer (at renderApplication.js:39)
componentDidMount
App.js:47:4
I have attempted manual installation, ensured that react-native-splash-screen is properly installed, and ran npm install, but the problem persists.