Created
January 13, 2021 17:28
-
-
Save asimonok/b0b33d7e0d581c279fea9119decfe31d to your computer and use it in GitHub Desktop.
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
const withLoadingListData = (BaseComponent) => | |
class WithLoadingListData extends Component { | |
state = { | |
list: [], | |
isLoading: true, | |
} | |
componentDidMount () { | |
setTimeout(() => { | |
this.setState({ | |
list: ['Apple', 'Orange', 'Pineapple'], | |
isLoading: false, | |
}) | |
}, 2000) | |
} | |
render () { | |
return this.state.isLoading | |
? 'Loading...' | |
: <BaseComponent list={this.state.list} /> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment