This repository has been archived by the owner on Jan 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Fix #148: Update deprecated history
and RoutingContext
for react-router
#155
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ddc7221
Rename react-router `RoutingContext` to `RouterContext`
remarkablemark c704861
Use `browserHistory` from react-router
remarkablemark 2290cdd
Remove `history` from client and as a dependency
remarkablemark 70d7fd5
Ignore swap files
remarkablemark 7e58422
Update README install instructions with removal of `history`
remarkablemark ccff218
Bump `react-router` to latest version 2.4.0
remarkablemark 86a8c43
Fix failing test in `server.js`
remarkablemark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ node_modules/ | |
.idea | ||
.project | ||
.settings | ||
*.swp | ||
logs | ||
*.log | ||
coverage/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,8 @@ | |
|
||
### Install | ||
```sh | ||
# In your express app, react-engine needs to be installed along | ||
# side react and optionally react-router (+ history, react-router's dependency) | ||
npm install react-engine react react-router history --save | ||
# In your express app, react-engine needs to be installed alongside react (react-router is optional) | ||
$ npm install react-engine [email protected] react-router --save | ||
``` | ||
|
||
### Usage On Server Side | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samsel the react router dependency update broke our app since our React Router code, with a package.json dependency of ~1.0.3, does not work with React Router 2.x. This package.json dependency chain is interesting since React Engine went from working, with a package.json dependency of ^3.3.0, to not working when React Engine update to 3.4. We run npm prune and then npm install, but the issue was not revealed until our build did a clean install of the node packages i.e. you may not experience this issue until node_modules is removed and re-installed. Maybe you want to consider a major version bump with this type of update?
The fix for this issue was to freeze React Router at 1.0.3 in our package.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JustinMGaiam Thanks for letting us know. What were the errors you were getting?
@samsel I just realized that for those still using
react-router@1
, I may need to update the logic here since thehistory
module is installed separately. What are your thoughts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@remarkablemark for our code base when we turn on React Router 2.x we end up without any errors and no HTML returned in the res.render callback for the express view. This was something we also tried before the package.json change was made to React Engine with the same result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@remarkablemark that patch should make react-engine seamlessly work with v1.x and 2.x. can you issue a PR?
@JustinMGaiam can you paste the error logs (for the one you encountered before freezing react-router to 1.0.3)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samsel I've added the fix to #159.
I know the original PR was meant to update the example app, so would you like me to cherry-pick the fix and make a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samsel and @remarkablemark here is what I get when I output the
err
variable for the callback of res.render in express:Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. at invariant ([project-path-removed]/node_modules/fbjs/lib/invariant.js:39:15) at instantiateReactComponent ([project-path-removed]/node_modules/react/lib/instantiateReactComponent.js:64:134) at [project-path-removed]/node_modules/react/lib/ReactServerRendering.js:41:31 at ReactServerRenderingTransaction.Mixin.perform ([project-path-removed]/node_modules/react/lib/Transaction.js:136:20) at Object.renderToString ([project-path-removed]/node_modules/react/lib/ReactServerRendering.js:40:24) at renderAndDecorate ([project-path-removed]/node_modules/react-engine/lib/server.js:112:30) at reactRouterMatchHandler ([project-path-removed]/node_modules/react-engine/lib/server.js:178:31) at [project-path-removed]/node_modules/react-router/lib/match.js:58:5 at [project-path-removed]/node_modules/react-router/lib/useRoutes.js:120:15 at done ([project-path-removed]/node_modules/react-router/lib/AsyncUtils.js:49:19)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JustinMGaiam Thanks for the error output. I've managed to reproduce it myself in the example app by installing
react-router@1
.The error was caused by not having a fallback for
react-router
v1 when I bumpedreact-router
to v2 in #148.I've made a fix in this commit. Waiting for @samsel to review it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@remarkablemark thanks for getting this fixed. I've published v3.4.1 with your changes.
@JustinMGaiam can you verify by pulling the latest (npm install)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samsel this is confirmed working with version React Engine v3.4.1, thanks for the fix!