Closed jurcovicova closed 7 years ago
I did another experiment, since splash screen hiding does not belong to the render method anyway. This time, I call hideSplash
method in componentWillMount
and also in AppState
event listener. The method counts how many times it was called during component life:
class App extends React.Component {
constructor(props) {
super(props)
this.state = {splashHidden: false, splashHiddenTimes: 0}
}
hideSplash() {
this.setState({splashHidden: true, splashHiddenTimes: (this.state.splashHiddenTimes || 0) + 1})
SplashScreen.hide()
}
componentWillMount() {
this.hideSplash()
AppState.addEventListener('change', (currentAppState) => {
if (currentAppState === 'active') {
this.hideSplash()
this.setState({currentAppState})
}
})
}
render() {
return (
<Text>{this.state.currentAppState} at {this.state.splashHidden ? 'it is hidden' : 'nope'} times {`${this.state.splashHiddenTimes}`}</Text>
)
}
}
module.exports = App
Right after install, everything works:
at it is hidden times 0
text on it. Then I put the app to the background and open it again via icon on home screen:
at it is hidden times 0
text on top of it.Lock the device again via power button and unlock it again a couple of times:
active at it is hidden times 2
text on top of it.active at it is hidden times 3
text on top of it.active at it is hidden times 4
text on top of it.I think that splash screen should disappear. The hideSplash
method is being called after each unlock, because the number is raising.
Is there something else I can do to make the splash disappear?
Is this same issue? https://github.com/mehcode/rn-splash-screen/issues/26
Probably not, we are using react-native 0.31.0 and his problem started with 0.34.0.
This was fixed as well in v4.0.0
I have very simple react-native application - all it does is to hide splash screen in
render
method and then showsRendering component
text.My app:
Right after install, everything works:
Rendering component
text on it.Then I put the app to the background and open it again via icon on home screen:
Rendering component
text on top of it.I think that splash screen should disappear.
Then I lock the device via power button and unlock it again (while the app is open):
Rendering component
text on top of it.I think that splash screen should disappear too in this case too.
I am using Samsung S5.