Skip to content

Instantly share code, notes, and snippets.

@sineau sineau/index.html
Created Jul 27, 2018

Embed
What would you like to do?
JS Bin // source https://jsbin.com/fahewaz
<!DOCTYPE html>
<html>
<head>
<script src="https://fb.me/react-15.1.0.js"></script>
<script src="https://fb.me/react-dom-15.1.0.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id='container'></div>
<script id="jsbin-javascript">
function CounterPresenter(props) {
return(
React.createElement("div", null,
React.createElement("p", null, props.counter),
React.createElement("button", {type: "button", onClick: props.onIncrement}, "Increase"),
React.createElement("button", {type: "button", onClick: props.onDecrement}, "Decrease")
)
)
}
class Counter extends React.Component {
constructor(props) {
super(props)
this.state = {
counter: 0
}
this.onIncrement = this.onIncrement.bind(this)
this.onDecrement = this.onDecrement.bind(this)
}
onIncrement() {
this.setState({
counter: this.state.counter + 1
})
}
onDecrement() {
this.setState({
counter: this.state.counter - 1
})
}
render() {
return(
React.createElement(CounterPresenter, {
counter: this.state.counter,
onIncrement: this.onIncrement,
onDecrement: this.onDecrement})
)
}
}
ReactDOM.render(
React.createElement(Counter, null),
document.getElementById('container')
);
</script>
<script id="jsbin-source-javascript" type="text/javascript">function CounterPresenter(props) {
return(
<div>
<p>{props.counter}</p>
<button type="button" onClick={props.onIncrement}>Increase</button>
<button type="button" onClick={props.onDecrement}>Decrease</button>
</div>
)
}
class Counter extends React.Component {
constructor(props) {
super(props)
this.state = {
counter: 0
}
this.onIncrement = this.onIncrement.bind(this)
this.onDecrement = this.onDecrement.bind(this)
}
onIncrement() {
this.setState({
counter: this.state.counter + 1
})
}
onDecrement() {
this.setState({
counter: this.state.counter - 1
})
}
render() {
return(
<CounterPresenter
counter={this.state.counter}
onIncrement={this.onIncrement}
onDecrement={this.onDecrement} />
)
}
}
ReactDOM.render(
<Counter />,
document.getElementById('container')
);</script></body>
</html>
function CounterPresenter(props) {
return(
React.createElement("div", null,
React.createElement("p", null, props.counter),
React.createElement("button", {type: "button", onClick: props.onIncrement}, "Increase"),
React.createElement("button", {type: "button", onClick: props.onDecrement}, "Decrease")
)
)
}
class Counter extends React.Component {
constructor(props) {
super(props)
this.state = {
counter: 0
}
this.onIncrement = this.onIncrement.bind(this)
this.onDecrement = this.onDecrement.bind(this)
}
onIncrement() {
this.setState({
counter: this.state.counter + 1
})
}
onDecrement() {
this.setState({
counter: this.state.counter - 1
})
}
render() {
return(
React.createElement(CounterPresenter, {
counter: this.state.counter,
onIncrement: this.onIncrement,
onDecrement: this.onDecrement})
)
}
}
ReactDOM.render(
React.createElement(Counter, null),
document.getElementById('container')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.