Skip to content

Instantly share code, notes, and snippets.

@Makazone
Created October 13, 2019 09:49
Show Gist options
  • Save Makazone/39903a1e64f7ff97b1b693e91c256067 to your computer and use it in GitHub Desktop.
Save Makazone/39903a1e64f7ff97b1b693e91c256067 to your computer and use it in GitHub Desktop.
import React from "react";
class ListComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
lastClickedButton: ""
};
}
render() {
return (
<div>
<h1>The last clicked button is {this.state.lastClickedButton}</h1>
<ul>
<li>
<button
onClick={() => {
this.setState({ lastClickedButton: "Create" });
this.props.createSomething();
}}
>
Create
</button>
</li>
<li>
<button
onClick={() => {
this.setState({ lastClickedButton: "Read" });
this.props.createSomething();
}}
>
Read
</button>
</li>
<li>
<button
onClick={() => {
this.setState({ lastClickedButton: "Update" });
this.props.createSomething();
}}
>
Update
</button>
</li>
<li>
<button
onClick={() => {
this.setState({ lastClickedButton: "Delete" });
this.props.createSomething();
}}
>
Delete
</button>
</li>
</ul>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment