Last active
February 7, 2017 07:23
-
-
Save frontsideair/7cba0a35afc77d49ebb2bf5b99e944f1 to your computer and use it in GitHub Desktop.
RR4 isolated test case
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- test here: https://esnextb.in/?gist=7cba0a35afc77d49ebb2bf5b99e944f1 --> | |
</head> | |
<body> | |
<div id="app"></div> | |
</body> | |
</html> |
This file contains 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, { Component } from 'react' | |
import { render } from 'react-dom' | |
import { MemoryRouter as Router, Match, Miss, Link } from 'react-router' | |
class App extends Component { | |
state = { num: 0 } | |
componentDidMount () { | |
this.interval = setInterval(() => this.setState(() => ({ num: Math.random() })), 1000) | |
} | |
componentWillUnmount () { | |
clearInterval(this.interval) | |
} | |
render () { | |
return ( | |
<Router> | |
<div> | |
<Match exactly pattern="/" component={() => <Home num={this.state.num} />} /> | |
</div> | |
</Router> | |
) | |
} | |
} | |
class Home extends Component { | |
state = { text: '' } | |
render () { | |
return ( | |
<div> | |
<label> | |
Number: { this.props.num } | |
<br /> | |
<input onChange={e => this.setState({ text: e.target.value })} value={this.state.text} /> | |
</label> | |
</div> | |
) | |
} | |
} | |
render(<App/>, document.querySelector('#app')) |
This file contains 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
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"react": "15.2.0-rc.2", | |
"react-dom": "15.2.0-rc.2", | |
"react-router": "4.0.0-2", | |
"babel-runtime": "6.11.6" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment