Created
February 14, 2016 20:45
-
-
Save spencercarli/7fbfa7f3a198028817ca to your computer and use it in GitHub Desktop.
Meteor Authentication from React Native - UI: Sign In - index.js
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
// RNApp/app/index.js | |
/* | |
* Removed from snippet for brevity | |
*/ | |
import LoggedOut from './loggedOut'; | |
export default React.createClass({ | |
getInitialState() { | |
return { | |
connected: false, | |
signedIn: false | |
} | |
}, | |
componentDidMount() { | |
ddpClient.connect((err, wasReconnect) => { | |
let connected = true; | |
if (err) connected = false; | |
this.setState({ connected: connected }); | |
}); | |
}, | |
changedSignedIn(status = false) { | |
this.setState({signedIn: status}); | |
}, | |
render() { | |
let body; | |
if (this.state.connected && this.state.signedIn) { | |
body = <LoggedIn changedSignedIn={this.changedSignedIn} />; // Note the change here as well | |
} else if (this.state.connected) { | |
body = <LoggedOut changedSignedIn={this.changedSignedIn} />; | |
} | |
return ( | |
<View style={styles.container}> | |
<View style={styles.center}> | |
{body} | |
</View> | |
</View> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment