Last active
February 19, 2016 07:02
-
-
Save danielweinmann/8ab67efdf51e773f4a59 to your computer and use it in GitHub Desktop.
"Cannot read property 'push' of undefined"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { AppRegistry, Component, Navigator, View, Text, TouchableHighlight } from 'react-native' | |
import { Router, Route, Actions } from 'react-native-router-flux' | |
class First extends Component { | |
render() { | |
return ( | |
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}> | |
<Text>This is shown when not signed in</Text> | |
<TouchableHighlight onPress={Actions.second}> | |
<Text>Next</Text> | |
</TouchableHighlight> | |
</View> | |
) | |
} | |
} | |
class Second extends Component { | |
render() { | |
return ( | |
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}> | |
<Text>Now we can sign in</Text> | |
<TouchableHighlight onPress={this.props.onSignIn}> | |
<Text>Sign in</Text> | |
</TouchableHighlight> | |
</View> | |
) | |
} | |
} | |
class NotSignedIn extends Component { | |
render() { | |
return ( | |
<Router> | |
<Route {...this.props} name="first" component={First} initial={true} title="First" /> | |
<Route {...this.props} name="second" component={Second} title="Second" /> | |
</Router> | |
) | |
} | |
} | |
class SignedIn extends Component { | |
render() { | |
return ( | |
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}> | |
<Text>This is shown when signed in</Text> | |
<TouchableHighlight onPress={this.props.onSignOut}> | |
<Text>Sign out</Text> | |
</TouchableHighlight> | |
</View> | |
) | |
} | |
} | |
class Root extends Component { | |
constructor(props, context) { | |
super(props, context) | |
this.state = { | |
signedIn: false, | |
} | |
} | |
handleSignIn() { | |
this.setState({signedIn: true}) | |
} | |
handleSignOut() { | |
this.setState({signedIn: false}) | |
} | |
render() { | |
const { signedIn } = this.state | |
if (signedIn) | |
return (<SignedIn onSignOut={this.handleSignOut.bind(this)} />) | |
return (<NotSignedIn onSignIn={this.handleSignIn.bind(this)} />) | |
} | |
} | |
AppRegistry.registerComponent('RoutesTest', () => Root) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Same happened to me.