0
votes

Issue Description

Trying to push a new screen with Navigation.push(this, { component: { name: 'awesome-places.AuthScreen' }}) And getting an error Exepction in HostFunction <unknown>

Error Screenshot

Steps to Reproduce / Code Snippets / Screenshots

Create RN app, install required modules (redux, react-redux, react-native-navigation, react-vector-icons) and run code on Android device.

Add relevant code, App.js and component that causes the error. I tried running Navigation.push with this.props.componentId but when I press the button there is no response

App.js

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

import AuthScreen from './src/screens/Auth/Auth';
import SharePlaceScreen from './src/screens/SharePlace/SharePlace';
import FindPlaceScreen from './src/screens/FindPlace/FindPlace';
import PlaceDetailScreen from './src/screens/PlaceDetail/PlaceDetail';
import configureStore from './src/store/configureStore';

const store = configureStore();

// Register Screens
Navigation.registerComponentWithRedux("awesome-places.AuthScreen", () => AuthScreen, Provider, store);
Navigation.registerComponentWithRedux("awesome-places.SharePlaceScreen", () => SharePlaceScreen, Provider, store);
Navigation.registerComponentWithRedux("awesome-places.FindPlaceScreen", () => FindPlaceScreen, Provider, store);
Navigation.registerComponent("awesome-places.PlaceDetailScreen", () => PlaceDetailScreen);

// Start an App
Navigation.events().registerAppLaunchedListener(() => {
  Navigation.setRoot({
    root: {
      component: {
        name: 'awesome-places.AuthScreen'
      }
    }
  });
});

FindPlace.js

import React, { Component } from 'react';
import { View, Text } from 'react-native';
import { connect } from 'react-redux';
import { Navigation } from 'react-native-navigation';

import PlaceList from '../../components/PlaceList/PlaceList';

class FindPlaceScreen extends Component {
        Navigation.push(this, {
            component: {
                name: 'awesome-places.AuthScreen',
            }
        })

    }

    render () {
        return(
            <View>
                <PlaceList places={this.props.places} onItemSelected={this.itemSelectedHandler} />
            </View>
        );
    }
}

const mapStateToProps = state => {
    return {
        places: state.places.places
    }
}

export default connect(mapStateToProps)(FindPlaceScreen);

Environment

  • React Native Navigation version: 2.17.0
  • React Native version: 0.59.4
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Android 7.1.2, Debug
1

1 Answers

0
votes

I noticed you're pushing the screen with this instead of an explicit componentId. When calling Navigation.push, the first argument needs to be a componentId. See the docs for reference.

Also, this might not be a problem, but registerComponentWithRedux is deprecated and you should register the screen with the new api