Skip to content

Instantly share code, notes, and snippets.

@johnantoni
Last active March 14, 2018 17:41
Show Gist options
  • Save johnantoni/ac5db25f7d0cc10868709719bac707d8 to your computer and use it in GitHub Desktop.
Save johnantoni/ac5db25f7d0cc10868709719bac707d8 to your computer and use it in GitHub Desktop.
react app.js
import React, { Component } from 'react';
import { Router, Route, Link, Redirect } from 'react-router-dom';
import { getCurrentUser } from './helpers';
class Home extends Component {
constructor(props) {
super(props);
this.state = {}
}
render() {
return (
<div>
<h2>Name: {this.props.full_name}</h2>
<p>Role: {this.props.role}</p>
</div>
)
}
}
class App extends Component {
state = {
user: [],
loadReady: false
}
async componentWillMount() {
let user = await getCurrentUser()
this.setState({
user: user
}, () => {
this.setState({
loadReady: true
})
})
}
render() {
if (this.state.loadReady) {
return (
<div>hello {user.name}</div>
<Profile userinfo={this.state.userinfo} />
)
else {
return null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment