React + MobX + React-Router (CSR & SSR)
git clone git@github.com:L-x-C/isomorphic-react-with-mobx.git
cd isomorphic-react-with-mobx
npm install
npm start
open http://localhost:3000
npm run server
open http://localhost:20000
Adding a onEnter
function to a component
@action
static onEnter({states, pathname, query, params}) {
progressStart();
return Promise.all([
menuActions.setTDK(states, '列表'),
jobActions.fetchJobList(states, query)
]);
}
In src/helpers/location.js
, there is a redirect
function, you can just import it and use.
The catchErr
in src/serverRender.js
will catch the redirect command and redirect as you wish.
It works on both server and client side.
import {redirect} from './helpers/location';
@action
static onEnter({states, query, params}) {
redirect('http://www.xxx.com');
}