Skip to content

Instantly share code, notes, and snippets.

@androidfanatic
Created March 23, 2020 07:19
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 androidfanatic/99d9753e8cbdba3c2857643c37fe72b8 to your computer and use it in GitHub Desktop.
Save androidfanatic/99d9753e8cbdba3c2857643c37fe72b8 to your computer and use it in GitHub Desktop.
export default class CounterApp extends React.Component {
constructor(props) {
super(props);
this.state = {
timeThen: ...,
timeNow: Date.now()
};
this.someAction = this.someAction.bind(this);
this.anotherAction = this.anotherAction.bind(this);
this.yetAnotherAction = this.yetAnotherAction.bind(this);
}
someAction() { /* some action */ }
anotherAction() { /* another action */ }
yetAnotherAction() { /* yet another action */ }
render() {
return (<div>
{this.state.timeThen > this.state.timeNow ? (
<>
<button onClick={this.someAction} />
<button onClick={this.anotherAction} />
</>
) : (
<button onClick={this.yetAnotherAction} />
)}</div>);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment