wix / react-native-navigation

A complete native navigation solution for React Native
https://wix.github.io/react-native-navigation/
MIT License
13.05k stars 2.67k forks source link

[Android] push makes the screen mount, unmount and then finally mount #5102

Closed rumbogs closed 5 years ago

rumbogs commented 5 years ago

Issue Description

On Android, using push with a stack based navigation, makes the screen mount, unmount and then finally mount before navigating to the path. iOS works fine.

Steps to Reproduce / Code Snippets / Screenshots

Only pasting the important parts:

import { Navigation } from 'react-native-navigation';

class InstallComponent extends React.PureComponent<Props> {
    componentDidMount() {
        console.log('componentDidMount');
    }
    componentWillUnmount() {
        console.log('componentWillUnmount');
    }
    render() {
        return <InstallScreen />;
    }
}

screens.set('install', props => {
    const { InstallComponent } = require('~/screens/install-component');
    return <InstallComponent {...props} />;
});

screens.forEach((ScreenComponent, key) =>
    Navigation.registerComponent(key, () => withProvider(ScreenComponent, store, persistor, key), () => ScreenComponent)
);

This will log

componentDidMount
componentWillUnmount
componentDidMount

Environment

rumbogs commented 5 years ago

Proved to be something with the custom withProvider.