Skip to content
This repository was archived by the owner on Jan 22, 2020. It is now read-only.

Commit 8fd56aa

Browse files
Ensure compatibility for both react-router v1 and v2
- Add fallback for react-router@1: - `history@1` used to be separately installed and instantiated - `RouterContext` used to be named `RoutingContext`
1 parent 0018d73 commit 8fd56aa

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/client.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ exports.boot = function boot(options, callback) {
5757
Router = require('react-router');
5858
RouterComponent = Router.Router;
5959
match = Router.match;
60-
browserHistory = Router.browserHistory;
60+
61+
// compatibility for both `react-router` v2 and v1
62+
browserHistory = Router.browserHistory || require('history').createHistory();
6163
} catch (err) {
6264
if (!Router && options.routes) {
6365
throw err;

lib/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ exports.create = function create(createOptions) {
6161
try {
6262
Router = require('react-router');
6363
match = Router.match;
64-
RouterContext = Router.RouterContext;
64+
65+
// compatibility for both `react-router` v2 and v1
66+
RouterContext = Router.RouterContext || Router.RoutingContext;
6567
} catch (err) {
6668
if (!Router && createOptions.routes) {
6769
throw err;

0 commit comments

Comments
 (0)