Skip to content

Commit d33dfac

Browse files
committed
Upgraded to react-router 0.12
1 parent 5add304 commit d33dfac

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ Based on [react-proxy-loader](https://github.com/webpack/react-proxy-loader), ad
99

1010
## Dependencies
1111

12-
Right now, this library depends on [bluebird](https://github.com/petkaantonov/bluebird) for promises, which is an amazing library. May be a little heavy, though, so feel free to send a PR if you'd rather it use something else.
12+
Which version to use depends on your version of `react-router`
13+
14+
| react-router | react-router-proxy-loader |
15+
| ---------------- | ------------------------- |
16+
| 0.11.x and below | 0.1.x |
17+
| 0.12.x and above | 0.2.x |
18+
1319

1420
## Usage
1521

index.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,30 @@ module.exports.pitch = function(remainingRequest) {
1313

1414
// BEGIN CHANGE
1515
' statics: {',
16-
' willTransitionTo: function(transition, params, query) {',
17-
' var Promise = require("bluebird");',
18-
' transition.wait(new Promise(function(resolve) {',
19-
' require.ensure([], function() {',
20-
' component = require(' + JSON.stringify(moduleRequest) + ');',
21-
' var resolveNow = true;',
22-
' if (component.willTransitionTo) { ',
23-
' var origWait = transition.wait;',
24-
' transition.wait = function(p) { resolveNow = false; p.then(resolve); }',
25-
' component.willTransitionTo(transition, params, query);',
26-
' transition.wait = origWait;',
27-
' } ',
28-
' resolveNow && resolve();',
29-
' });',
30-
' }));',
16+
' willTransitionTo: function(transition, params, query, callback) {',
17+
' require.ensure([], function() {',
18+
' component = require(' + JSON.stringify(moduleRequest) + ');',
19+
' if (component.willTransitionTo) { ',
20+
' component.willTransitionTo(transition, params, query, callback);',
21+
' if (component.willTransitionTo.length < 4) {',
22+
' callback(); ',
23+
' }',
24+
' } ',
25+
' else {',
26+
' callback();',
27+
' }',
28+
' });',
3129
' },',
32-
' willTransitionFrom: function(transition, params, query) {',
33-
' component && component.willTransitionFrom && component.willTransitionFrom(transition, params, query);',
30+
' willTransitionFrom: function(transition, component, callback) {',
31+
' if (component && component.willTransitionFrom) {',
32+
' component.willTransitionFrom(transition, component, callback);',
33+
' if (component.willTransitionFrom.length < 3) {',
34+
' callback(); ',
35+
' }',
36+
' }',
37+
' else {',
38+
' callback();',
39+
' }',
3440
' }',
3541
' }, ',
3642
// END CHANGE

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-router-proxy-loader",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Dynamically load react-router components on-demand",
55
"main": "index.js",
66
"scripts": {
@@ -23,7 +23,6 @@
2323
},
2424
"homepage": "https://github.com/odysseyscience/react-router-proxy-loader",
2525
"peerDependencies": {
26-
"bluebird": "*",
27-
"react-router": "0.11.x"
26+
"react-router": "^0.12.0"
2827
}
2928
}

0 commit comments

Comments
 (0)