Created
April 26, 2019 17:22
-
-
Save rzkhosroshahi/a9ebd0ea57080a28ff2c74e21dae5207 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
import React, { Component } from 'react'; | |
import Fetch from '../Utilities/fetch'; | |
import List from './render-list'; | |
import WithLoading from './handle-loading'; | |
const ListWithLoading = WithLoading(List); | |
class FetchinUserInfo extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { info: null, isLoading: false, error: false }; | |
} | |
componentDidMount() { | |
Fetch() | |
.then(data => | |
this.setState({ info: data, isLoading: false, error: false }), | |
) | |
.catch(error => this.setState({ info: null, isLoading: true, error })); | |
} | |
render() { | |
const { isLoading, info, error } = this.state; | |
return <ListWithLoading isLoading={isLoading} info={info} error={error} />; | |
} | |
} | |
export default FetchinUserInfo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment