Created
October 13, 2019 09:49
-
-
Save Makazone/39903a1e64f7ff97b1b693e91c256067 to your computer and use it in GitHub Desktop.
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 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