0

index.js

import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import Login from './src/screens/Login';
import Secured from './src/screens/Secured';
import NewPass from './src/screens/NewPass';
import { Provider } from 'react-redux';
import store from './store'; //Import the store

class ReactNativeStormpath extends Component {

    state = {
      isLoggedIn: false      
    }

    render() {

      if (this.state.isLoggedIn) 
        return ( 
          <Provider store={store}>
            <Secured 
              onLogoutPress={() => this.setState({isLoggedIn: false})}
            />
          </Provider>
        )
      else 
        return (
          <Provider store={store}>
            <Login 
                onLoginPress={() =>  this.props.navigation.navigate('NewPass')}
            />
          </Provider>
        )
    }  
}

AppRegistry.registerComponent('ReactNativeStormpath', () => ReactNativeStormpath);

I receive "undefined is not an object", or the button doesn´t do anything, i've followed almost all post and couldn't find a way to navigate between views in react native, this can't be that difficult.

bennygenel
  • 23,896
  • 6
  • 65
  • 78
Guille
  • 370
  • 2
  • 7
  • 21
  • To be able to navigate you need to have a navigation structure via a library or a custom one. Do you have such implementation? – bennygenel Jun 19 '18 at 14:53
  • i've followed: https://reactnavigation.org/docs/en/hello-react-navigation.html I don't have an "App" class, like: "export default class App", i don't know where to add the "const RootStack = createStackNavigator(" – Guille Jun 19 '18 at 15:02
  • Then please update your question showing that your navigation stack – bennygenel Jun 19 '18 at 15:03
  • @bennygenel i've updated my previous comment – Guille Jun 19 '18 at 15:05
  • When you create your project initially you should have 2 files. `index.js` and `app.js`. You should edit your `app.js` file and add navigation stack to there as it shows in tutorial. – bennygenel Jun 19 '18 at 15:08
  • i don't have an App.js file, i've created the project follow this: https://github.com/stormpath/stormpath-react-native-example?utm_source=syndicate&utm_campaign=scotchio-feb2017&utm_medium=post – Guille Jun 19 '18 at 15:11
  • That is a year old project which has an outdated file structure. You should use a more resent version of a starter project – bennygenel Jun 19 '18 at 15:14
  • oh i see. thanks. I've also posted this: https://stackoverflow.com/questions/50928633/cannot-linking-openurl-whatsup-message-in-react-native?noredirect=1#comment88856237_50928633 May be you can help too. thanks!!! – Guille Jun 19 '18 at 16:49

0 Answers0