11/* eslint no-console: 0 */
22
33import fsp from 'fs-promise' ;
4+ import createLocation from 'history/lib/createLocation' ;
45import path from 'path' ;
56import React from 'react' ;
67import ReactDOMServer from 'react-dom/server' ;
7- import Router from 'react-router' ;
8- import Location from 'react-router/lib/Location' ;
8+ import { match , RoutingContext } from 'react-router' ;
99
1010import Root from './src/Root' ;
1111import routes from './src/Routes' ;
@@ -32,10 +32,11 @@ const readmeDest = path.join(docsBuilt, 'README.md');
3232function generateHTML ( fileName ) {
3333 return new Promise ( resolve => {
3434 const urlSlug = fileName === 'index.html' ? '/' : `/${ fileName } ` ;
35+ const location = createLocation ( urlSlug ) ;
3536
36- Router . run ( routes , new Location ( urlSlug ) , ( error , initialState ) => {
37+ match ( { routes, location } , ( error , redirectLocation , renderProps ) => {
3738 let html = ReactDOMServer . renderToString (
38- < Router { ...initialState } />
39+ < RoutingContext { ...renderProps } />
3940 ) ;
4041 html = '<!doctype html>' + html ;
4142 let write = fsp . writeFile ( path . join ( docsBuilt , fileName ) , html ) ;
0 commit comments