Created
February 8, 2016 18:05
-
-
Save caius/dac0ffe734f75ad90d8a 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js" type="text/javascript" charset="utf-8"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js" type="text/javascript" charset="utf-8"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js" type="text/javascript" charset="utf-8"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react-router/1.0.3/ReactRouter.js" type="text/javascript" charset="utf-8"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/history/2.0.0/History.js" type="text/javascript" charset="utf-8"></script> | |
| <script type="text/babel"> | |
| var CHD = { | |
| History: History.useQueries(History.createHistory)() | |
| } | |
| class Actions { | |
| constructor() { | |
| console.log("CHD.Actions created!"); | |
| s = {pageNumber: 1} | |
| if (CHD.History.location.query.page) { | |
| s.pageNumber = CHD.History.location.query.page; | |
| } | |
| this.setState(s) | |
| } | |
| setState(state) { | |
| this.state = state | |
| } | |
| } | |
| CHD.Actions = new Actions | |
| var Page = React.createClass({ | |
| console.log(CHD.Actions) | |
| render() { | |
| return (<div> | |
| This is page {CHD.Actions.state.pageNumber}. <a href="#" onClick={CHD.Actions.nextPageClick}>Onwards →</a> | |
| </div>) | |
| } | |
| }); | |
| ReactDOM.render( | |
| <ReactRouter.Router history={CHD.History}> | |
| <ReactRouter.Route path="*" component={Page}> | |
| </ReactRouter.Route> | |
| </ReactRouter.Router>, | |
| document.getElementById("main") | |
| ); | |
| </script> | |
| </head> | |
| <body onload="console.log('body onload')"> | |
| <div id="main"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment