Skip to content

Instantly share code, notes, and snippets.

@agenthunt
Last active June 7, 2018 19:09
Show Gist options
  • Save agenthunt/6496bd5ac6ddbe15f47f912a2d455e09 to your computer and use it in GitHub Desktop.
Save agenthunt/6496bd5ac6ddbe15f47f912a2d455e09 to your computer and use it in GitHub Desktop.
hello-react-custom-renderer-counter.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
counter: 0
};
}
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
<div className="button-container">
<button className="decrement-button" onClick={() => this.setState({ counter: this.state.counter - 1 })}>
-
</button>
<div className="counter-text">{this.state.counter}</div>
<button className="increment-button" onClick={() => this.setState({ counter: this.state.counter + 1 })}>
+
</button>
</div>
</p>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment