Update history/react-router
This commit is contained in:
@ -4,7 +4,7 @@ import React from 'react';
|
||||
import debug from 'debug';
|
||||
import { Router } from 'react-router';
|
||||
import { routeReducer as routing, syncHistory } from 'react-router-redux';
|
||||
import { createLocation, createHistory } from 'history';
|
||||
import { createHistory } from 'history';
|
||||
|
||||
import app$ from '../common/app';
|
||||
import provideStore from '../common/app/provide-store';
|
||||
@ -23,7 +23,7 @@ const serviceOptions = { xhrPath: '/services' };
|
||||
|
||||
Rx.config.longStackSupport = !!debug.enabled;
|
||||
const history = createHistory();
|
||||
const appLocation = createLocation(
|
||||
const appLocation = history.createLocation(
|
||||
location.pathname + location.search
|
||||
);
|
||||
const routingMiddleware = syncHistory(history);
|
||||
|
@ -21,7 +21,7 @@ const routes = { components: App, ...childRoutes };
|
||||
|
||||
//
|
||||
// createApp(settings: {
|
||||
// location?: Location,
|
||||
// location?: Location|String,
|
||||
// history?: History,
|
||||
// initialState?: Object|Void,
|
||||
// serviceOptions?: Object,
|
||||
@ -65,13 +65,13 @@ export default function createApp({
|
||||
const store = compose(...enhancers)(createStore)(reducer, initialState);
|
||||
|
||||
// createRouteProps({
|
||||
// location: LocationDescriptor,
|
||||
// redirect: LocationDescriptor,
|
||||
// history: History,
|
||||
// routes: Object
|
||||
// }) => Observable
|
||||
return createRouteProps({ routes, location, history })
|
||||
.map(([ nextLocation, props ]) => ({
|
||||
nextLocation,
|
||||
.map(([ redirect, props ]) => ({
|
||||
redirect,
|
||||
props,
|
||||
reducer,
|
||||
store
|
||||
|
@ -76,7 +76,7 @@ export class JobTotal extends PureComponent {
|
||||
promoApplied: PropTypes.bool
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
componentWillMount() {
|
||||
if (!this.props.id) {
|
||||
this.props.push('/jobs');
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ export class JobPreview extends PureComponent {
|
||||
push: PropTypes.func
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
componentWillMount() {
|
||||
const { push, job } = this.props;
|
||||
// redirect user in client
|
||||
if (!job || !job.position || !job.description) {
|
||||
|
@ -74,7 +74,7 @@
|
||||
"gulp-util": "^3.0.6",
|
||||
"helmet": "^1.1.0",
|
||||
"helmet-csp": "^1.0.3",
|
||||
"history": "^1.17.0",
|
||||
"history": "^2.0.0",
|
||||
"jade": "^1.11.0",
|
||||
"json-loader": "~0.5.2",
|
||||
"less": "^2.5.1",
|
||||
@ -108,8 +108,8 @@
|
||||
"react-motion": "~0.4.2",
|
||||
"react-pure-render": "^1.0.2",
|
||||
"react-redux": "^4.0.6",
|
||||
"react-router": "^1.0.0",
|
||||
"react-router-bootstrap": "https://github.com/FreeCodeCamp/react-router-bootstrap.git#freecodecamp",
|
||||
"react-router": "^2.0.0",
|
||||
"react-router-bootstrap": "~0.20.1",
|
||||
"react-toastr": "^2.4.0",
|
||||
"react-router-redux": "^2.1.0",
|
||||
"react-vimeo": "~0.1.0",
|
||||
|
@ -1,6 +1,5 @@
|
||||
import React from 'react';
|
||||
import { RoutingContext } from 'react-router';
|
||||
import { createLocation } from 'history';
|
||||
import { RouterContext } from 'react-router';
|
||||
import debug from 'debug';
|
||||
|
||||
import renderToString from '../../common/app/utils/render-to-string';
|
||||
@ -39,15 +38,15 @@ export default function reactSubRouter(app) {
|
||||
|
||||
function serveReactApp(req, res, next) {
|
||||
const serviceOptions = { req };
|
||||
const location = createLocation(req.path);
|
||||
|
||||
// returns a router wrapped app
|
||||
app$({
|
||||
location,
|
||||
location: req.path,
|
||||
serviceOptions
|
||||
})
|
||||
// if react-router does not find a route send down the chain
|
||||
.filter(({ props }) => {
|
||||
.filter(({ redirect, props }) => {
|
||||
if (!props && redirect) {
|
||||
res.redirect(redirect.pathname + redirect.search);
|
||||
}
|
||||
if (!props) {
|
||||
log(`react tried to find ${location.pathname} but got 404`);
|
||||
return next();
|
||||
@ -58,7 +57,7 @@ export default function reactSubRouter(app) {
|
||||
log('render react markup and pre-fetch data');
|
||||
|
||||
return renderToString(
|
||||
provideStore(React.createElement(RoutingContext, props), store)
|
||||
provideStore(React.createElement(RouterContext, props), store)
|
||||
)
|
||||
.map(({ markup }) => ({ markup, store }));
|
||||
})
|
||||
|
@ -28,7 +28,6 @@ export default function getJobServices(app) {
|
||||
},
|
||||
read(req, resource, params, config, cb) {
|
||||
const id = params ? params.id : null;
|
||||
console.log('params', params);
|
||||
if (id) {
|
||||
return Job.findById(id)
|
||||
.then(job => cb(null, job.toJSON()))
|
||||
|
Reference in New Issue
Block a user