Skip to content

Instantly share code, notes, and snippets.

@danielweinmann
Last active February 19, 2016 07:02
Show Gist options
  • Save danielweinmann/8ab67efdf51e773f4a59 to your computer and use it in GitHub Desktop.
Save danielweinmann/8ab67efdf51e773f4a59 to your computer and use it in GitHub Desktop.
"Cannot read property 'push' of undefined"
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)
@PrimeObjects
Copy link

Same happened to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment