{"size": 899, "ext": "js", "max_stars_repo_path": "src/components/profile/index.js", "max_stars_repo_name": "xarephonic/preact-testbed", "max_stars_repo_stars_event_min_datetime": "2018-07-20T14:17:11.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-20T14:17:11.000Z", "max_issues_repo_path": "src/components/profile/index.js", "max_issues_repo_name": "xarephonic/preact-testbed", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/profile/index.js", "max_forks_repo_name": "xarephonic/preact-testbed", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.9777777778, "max_line_length": 68, "alphanum_fraction": 0.5561735261}
import { h, Component } from 'preact';
import style from './style.less';
import axios from 'axios';

export default class Profile extends Component {
	state = {};
	componentDidMount() {
		axios.get(`http://localhost:8090/${this.props.user}`)
			.then(resp => {
				this.setState({
					...resp.data
				})
			});
	}

	componentWillReceiveProps(nextprops) {
		axios.get(`http://localhost:8090/${nextprops.user}`)
			.then(resp => {
				this.setState({
					...resp.data
				});
			});
	}

	render() {
		return (
			<div class={style.profile}>
				<h1>{this.state.name}</h1>
				{ this.state.images && ( <img src={this.state.images[1].url}/>)}
				{ this.state.genres && (
					<ul>
						{this.state.genres.map(genre => {
							return (<li>{genre}</li>)
						})}
					</ul>
				)}
				{ this.state.followers && (
					<p>Followers: {this.state.followers.total}</p>
					)
				}
			</div>
		);
	}
}
