Forked from YonasBerhe/gist:ce2fea747650ee7d9d5c
Last active
January 4, 2016 19:11
-
-
Save ianobermiller/78eec7c7684869d07757 to your computer and use it in GitHub Desktop.
Hoisting issue using radium
This file contains hidden or 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 Radium from 'radium'; | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
// import Radium, { Style } from 'radium'; | |
var FakeUser = React.createClass({ | |
getInitialState: function() { | |
return {firstname: '', lastName: '', gender: '', location: '', email: '', username: '', password: '', picture: ''}; | |
}, | |
componentDidMount: function() { | |
$.get(this.props.source, function(result) { | |
var fakey = result.results[0].user | |
console.log(fakey); | |
// var fakey = result.results[0].user; | |
if (this.isMounted()) {this.setState({firstname: fakey.name.first, lastName: fakey.name.last, gender: fakey.gender, location: fakey.location.city, email: fakey.email, username: fakey.username, password: fakey.password, picture: fakey.picture.medium});} | |
}.bind(this)); | |
}, | |
render() { | |
return ( | |
<div> | |
<div className="picturetype" style={styles.image}> | |
<img src={this.state.picture}/> | |
</div> | |
<div className="card1" style={styles.body}> | |
<span className="firstName" style={styles.font}> | |
{this.state.firstname} | |
</span> | |
<span className="lastName"> | |
{this.state.lastName} | |
</span> | |
<span className="genName"> | |
{this.state.gender} | |
</span> | |
<span className="locArea"> | |
{this.state.location} | |
</span> | |
</div> | |
</div> | |
); | |
} | |
}); | |
FakeUser = Radium(FakeUser); | |
document.body.style.backgroundColor = "#3B5998"; | |
var styles = { | |
image: { | |
background: "#fff" | |
}, | |
font: { | |
fontSize: 50 | |
} | |
}; | |
ReactDOM.render( | |
<FakeUser source="https://randomuser.me/api/"/>, document.getElementById('app')); | |
// export default (FakeUser); | |
export default FakeUser; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment