Skip to content

Instantly share code, notes, and snippets.

@Tautorn
Last active June 24, 2019 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tautorn/de66e05daa3aa5a29a63538e5fa38c56 to your computer and use it in GitHub Desktop.
Save Tautorn/de66e05daa3aa5a29a63538e5fa38c56 to your computer and use it in GitHub Desktop.
React HOOK class scope example
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