Created
July 25, 2019 14:54
-
-
Save andrew-oko-odion/4818e719caa421253bdceb042a342d14 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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