Last active
March 14, 2018 17:41
-
-
Save johnantoni/ac5db25f7d0cc10868709719bac707d8 to your computer and use it in GitHub Desktop.
react app.js
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 { 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