Skip to content

Instantly share code, notes, and snippets.

@theonlyrao
Last active July 29, 2016 04:11
Show Gist options
  • Save theonlyrao/69aa0e53a2acf9de3611d6da3ea79b85 to your computer and use it in GitHub Desktop.
Save theonlyrao/69aa0e53a2acf9de3611d6da3ea79b85 to your computer and use it in GitHub Desktop.
First attempt at render React component in new div
import React from 'react';
import ReactDOM from 'react-dom';
const Letter = React.createClass({
render() {
return (
// lots of HTML stuff here...
)
}
});
var CapitalAButton = React.createClass({
getInitialState: function(){
return { showCapitalA: false };
},
showCapitalA: function(){
this.setState({
showCapitalA: true
});
},
render: function() {
return (
<div id="capital-button" onClick={this.showCapitalA}>
A
{ this.state.showCapitalA? ReactDOM.render(<Letter />, document.querySelector('#letter')) : null }
</div>
)
}
});
var ButtonChoices = React.createClass({
render: function() {
return (
<CapitalAButton />
)
}
});
ReactDOM.render(
<div id="a">
<ButtonChoices />
</div>,
document.querySelector('#button-group')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment