Skip to content

Instantly share code, notes, and snippets.

@spencercarli
Created February 14, 2016 20:45
Show Gist options
  • Save spencercarli/7fbfa7f3a198028817ca to your computer and use it in GitHub Desktop.
Save spencercarli/7fbfa7f3a198028817ca to your computer and use it in GitHub Desktop.
Meteor Authentication from React Native - UI: Sign In - index.js
// 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