Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Navigation Invariant violation: Attempt to get native tag

I am getting an error when trying to set up a simple navigation app using react-navigation.

Here's index.js:

/** @format */

import { AppRegistry } from 'react-native';
import { createStackNavigator } from 'react-navigation';
import SecondScreen from './app/screens/SecondScreen';
import FirstScreen from './app/screens/FirstScreen';
import { name as appName } from './app.json';

const App = createStackNavigator(
  {
    SecondScreen,
    FirstScreen,
  },
  {
    initialRouteName: 'FirstScreen',
  },
);

AppRegistry.registerComponent(appName, () => App);

Here's FirstScreen.js:

import React, { Component } from 'react';
import { Button } from 'react-native';

export default class ReadingScreen extends Component {
  static navigationOptions = {
    header: null,
  };

  render() {
    return <Button title="CLICK ME" onPress={this.props.navigation.navigate('SelectScreen')} />;
  }
}

When I make the initial screen the SecondScreen everything is fine, but when it's like this I get this error:

Invariant Violation: Attempt to get native tag from node not marked as "native"

Help would be appreciated! I've been looking for a solution all day!

Here are my versions:

"react": "16.4.1",
"react-native": "0.56.0",
"react-navigation": "^2.12.0"
like image 691
Jokas Lokas Avatar asked Oct 29 '22 06:10

Jokas Lokas


1 Answers

Same error, i can't navigate, it just hangs out and throws same error but when i am debugging remotely it works, i think it has to do with cocoa pods being installed in xcode project or something. Weird thing is that a few days ago this project did run OK.

The only different thing i did is to reinstall and update dependences in react, maybe it's an error on current react-navigation version i was version 2.11.2 and when now it is 2.12.

Yes!! Solved it, it was the version. I downgrated react-navigation from 2.12.0 to 2.11.2 and it worked!

like image 79
Juan Carlos Méndez Guevara Avatar answered Nov 15 '22 13:11

Juan Carlos Méndez Guevara