Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrew-oko-odion/4818e719caa421253bdceb042a342d14 to your computer and use it in GitHub Desktop.
Save andrew-oko-odion/4818e719caa421253bdceb042a342d14 to your computer and use it in GitHub Desktop.
class AuthScreen extends React.Component {
constructor(props){
super(props);
this.state = { loading: false, isAuthenticated: true }
}
render(){
const Loading = (props) =>
<p> Loading.... </p>
const LoginScreen = (props) =>
<div>
This is a login screen
</div>;
const Default = (props) =>
<div>
This is default screen
<button onClick={props.clicked}> logout </button>
</div>;
return (
<div>
{(() => {
if (this.state.loading)
return <Loading />;
else if (!this.state.isAuthenticated)
return <LoginScreen />;
else
return <Default clicked={() => this.setState({isAuthenticated: false })} />;
})()}
</div>
);
}
}
export default AuthScreen;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment