[Ivan Diaz] - Update react-router

This commit is contained in:
Ivan Diaz 2015-10-06 19:50:35 -03:00
parent 673ccae39e
commit 6b1aa7aa60
7 changed files with 20 additions and 21 deletions

View File

@ -51,7 +51,7 @@
"react": "^0.13.x",
"react-document-title": "^1.0.2",
"react-motion": "^0.3.0",
"react-router": "^0.13.x",
"react-router": "^1.0.0-rc1",
"reflux": "^0.2.9",
"run-sequence": "^1.1.1",
"superagent": "^1.2.0",

View File

@ -13,8 +13,7 @@ var App = React.createClass({
render() {
return (
<div>
<RouteHandler params={this.props.params}
query={this.props.query} />
{this.props.children}
</div>
);
},

View File

@ -1,5 +1,6 @@
import React from 'react/addons';
import {Route, NotFoundRoute, DefaultRoute} from 'react-router';
import {Router, Route, IndexRoute} from 'react-router';
import CreateBrowserHistory from 'react-router/node_modules/history/lib/createBrowserHistory';
import App from 'app/App';
import DemoPage from 'app/demo/components-demo-page';
@ -10,14 +11,16 @@ import MainSignUpPage from 'app/main/main-signup/main-sign
export default (
<Route handler={App} path='/'>
<Router history={CreateBrowserHistory()}>
<Route component={App} path='/'>
<Route name='main' path='/app' handler={MainLayout}>
<DefaultRoute name='home' handler={MainHomePage} />
<Route name='signup' path='/app/signup' handler={MainSignUpPage}/>
</Route>
<Route path='/app' component={MainLayout}>
<IndexRoute component={MainHomePage} />
<Route path='signup' component={MainSignUpPage}/>
</Route>
<Route name='Demo' path='/demo' handler={DemoPage} />
<Route name='Demo' path='demo' component={DemoPage} />
</Route>
</Route>
</Router>
);

View File

@ -8,6 +8,4 @@ if ( process.env.NODE_ENV !== 'production' ) {
window.React = React;
}
Router.run(routes, Router.HistoryLocation, (Handler, state) => {
React.render(<Handler params={state.params} query={state.query} />, document.getElementById('app'));
});
React.render(routes, document.getElementById('app'));

View File

@ -9,8 +9,8 @@ var MainLayoutHeader = React.createClass({
return (
<div className="main-layout-header">
<div className="main-layout-header--login-links">
<Button type="clean" route={{to:'home'}}>{i18n('LOG_IN')}</Button>
<Button type="clean" route={{to:'signup'}}>Sign up</Button>
<Button type="clean" route={{to:'/app'}}>{i18n('LOG_IN')}</Button>
<Button type="clean" route={{to:'/app/signup'}}>Sign up</Button>
<Button type="clean" onClick={function () {CommonActions.changeLanguage('es');}}>Spanish</Button>
<Button type="clean" onClick={function () {CommonActions.changeLanguage('en');}}>English</Button>
</div>

View File

@ -12,8 +12,7 @@ var MainLayout = React.createClass({
<MainHeader />
<RouteHandler params={this.props.params}
query={this.props.query} />
{this.props.children}
<MainFooter />

View File

@ -1,12 +1,12 @@
import React from 'react/addons';
import classNames from 'classnames';
import {Navigation} from 'react-router';
import {History} from 'react-router';
import callback from 'utils/callback';
var Button = React.createClass({
mixins: [Navigation],
mixins: [History],
propTypes: {
children: React.PropTypes.node,
@ -49,7 +49,7 @@ var Button = React.createClass({
handleClick() {
if (this.props.route) {
this.transitionTo(this.props.route.to, this.props.route.param, this.props.route.query);
this.history.pushState(null, this.props.route.to, this.props.route.query);
}
}
});