From e9a9c3253dc869f9561da3caef7ec021a3bbad83 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Tue, 29 Sep 2015 23:45:13 +0200 Subject: [PATCH] [reactV14] add history dependency --- docs/package.json | 3 ++- docs/src/app/app-routes.jsx | 18 +++++++++--------- docs/src/app/app.jsx | 6 ++++-- docs/src/app/components/master.jsx | 6 +++--- docs/src/app/components/pages/home.jsx | 12 ++++++++---- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/docs/package.json b/docs/package.json index dc365d1a114c0a..4f3e11d76af768 100644 --- a/docs/package.json +++ b/docs/package.json @@ -12,7 +12,8 @@ "build": "webpack --config webpack-production.config.js --progress --colors --profile" }, "dependencies": { - "codemirror": "^5.5.0" + "codemirror": "^5.5.0", + "history": "^1.11.1" }, "devDependencies": { "raw-loader": "^0.5.1", diff --git a/docs/src/app/app-routes.jsx b/docs/src/app/app-routes.jsx index 13d33824bd743d..122fdaa036662b 100644 --- a/docs/src/app/app-routes.jsx +++ b/docs/src/app/app-routes.jsx @@ -46,15 +46,15 @@ const TimePicker = require('./components/pages/components/time-picker'); const Toolbars = require('./components/pages/components/toolbars'); -/** Routes: https://github.com/rackt/react-router/blob/master/docs/api/components/Route.md - * - * Routes are used to declare your view hierarchy. - * - * Say you go to http://material-ui.com/#/components/paper - * The react router will search for a route named 'paper' and will recursively render its - * handler and its parent handler like so: Paper > Components > Master - */ - +/** + * Routes: https://github.com/rackt/react-router/blob/master/docs/api/components/Route.md + * + * Routes are used to declare your view hierarchy. + * + * Say you go to http://material-ui.com/#/components/paper + * The react router will search for a route named 'paper' and will recursively render its + * handler and its parent handler like so: Paper > Components > Master + */ const AppRoutes = ( diff --git a/docs/src/app/app.jsx b/docs/src/app/app.jsx index 1d2c3a0c459911..75b229f89ca87f 100644 --- a/docs/src/app/app.jsx +++ b/docs/src/app/app.jsx @@ -2,7 +2,9 @@ const React = require('react'); const ReactDOM = require('react-dom'); const {Router} = require('react-router'); const AppRoutes = require('./app-routes.jsx'); -const injectTapEventPlugin = require("react-tap-event-plugin"); +const injectTapEventPlugin = require('react-tap-event-plugin'); +const createBrowserHistory = require('history/lib/createBrowserHistory'); +const history = createBrowserHistory() //Needed for React Developer Tools window.React = React; @@ -17,6 +19,6 @@ injectTapEventPlugin(); * Render the main app component. You can read more about the react-router here: * https://github.com/rackt/react-router/blob/master/docs/guides/overview.md */ -ReactDOM.render( +ReactDOM.render( {AppRoutes} , document.getElementById('app')); diff --git a/docs/src/app/components/master.jsx b/docs/src/app/components/master.jsx index 253f681f0f08cb..e0c9f062054e8e 100644 --- a/docs/src/app/components/master.jsx +++ b/docs/src/app/components/master.jsx @@ -202,17 +202,17 @@ const Master = React.createClass({ value="1" label="GETTING STARTED" style={styles.tab} - route="get-started" /> + route="/get-started" /> + route="/customization"/> + route="/components"/> diff --git a/docs/src/app/components/pages/home.jsx b/docs/src/app/components/pages/home.jsx index 04386ae2952e66..dbff278d688245 100644 --- a/docs/src/app/components/pages/home.jsx +++ b/docs/src/app/components/pages/home.jsx @@ -1,5 +1,5 @@ const React = require('react'); -const Router = require('react-router'); +const {History} = require('react-router'); const { Mixins, RaisedButton, Styles } = require('material-ui'); const HomeFeature = require('./home-feature'); const FullWidthSection = require('../full-width-section'); @@ -12,7 +12,11 @@ const DefaultRawTheme = Styles.LightRawTheme; const HomePage = React.createClass({ - mixins: [StylePropable, StyleResizable], + mixins: [ + StylePropable, + StyleResizable, + History, + ], contextTypes: { router: React.PropTypes.func @@ -208,8 +212,8 @@ const HomePage = React.createClass({ }, _onDemoClick() { - this.context.router.transitionTo('components'); - } + this.history.pushState(null, '/components'); + }, }); module.exports = HomePage;