Last active
June 24, 2019 09:51
-
-
Save Tautorn/de66e05daa3aa5a29a63538e5fa38c56 to your computer and use it in GitHub Desktop.
React HOOK class scope example
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
import React, { Component } from 'react' | |
class Twitter extends Component { | |
state = { | |
isLoading: true | |
} | |
constructor(props) { | |
super(props) | |
} | |
componentDidMount() { | |
window.setTimeout(() => { | |
this.setState({ isLoading: false }) | |
}, 2000) | |
} | |
render() { | |
return ( | |
<div> | |
{ | |
isLoading ? ( | |
<div>Loading...</div> | |
) : ( | |
<div>Hello Twitter</div> | |
) | |
} | |
</div> | |
) | |
} | |
} | |
export default Twitter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment