Skip to content

Instantly share code, notes, and snippets.

@buckatech
Created October 1, 2018 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buckatech/4d16ec7d778c49c6e0254eb5fd0d231a to your computer and use it in GitHub Desktop.
Save buckatech/4d16ec7d778c49c6e0254eb5fd0d231a to your computer and use it in GitHub Desktop.
const React = require('react');
const ReactDOM = require('react-dom');
const PropTypes = require('prop-types')
require('./index.css');
const root = document.getElementById("root");
class ChangeColors extends React.Component {
constructor() {
super();
this.state = { color: "black" };
}
handleClick() {
this.setState(state => ({
colorIs: !state.isToggleOn
}));
}
render() {
const redButton = () => {
this.setState({ color: "red" });
};
const blueButton = () => {
this.setState({ color: "blue" });
};
const greenButton = () => {
this.setState({ color: "green" });
};
const style = { color: this.state.color };
return (
<div>
<h1 style={style}>Change My Colour!</h1>
<p>
<button onClick={redButton}>
Red
</button>
<button onClick={blueButton}>
Blue
</button>
<button onClick={greenButton}>
Green
</button>
</p>
</div>
);
}
}
ReactDOM.render(<ChangeColors />, root);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment