Skip to content

Instantly share code, notes, and snippets.

@rzkhosroshahi
Created April 26, 2019 17:22
Show Gist options
  • Save rzkhosroshahi/a9ebd0ea57080a28ff2c74e21dae5207 to your computer and use it in GitHub Desktop.
Save rzkhosroshahi/a9ebd0ea57080a28ff2c74e21dae5207 to your computer and use it in GitHub Desktop.
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