Skip to content

Commit

Permalink
Force route component remount. Necessary when rendering same componen…
Browse files Browse the repository at this point in the history
…t as previous route
  • Loading branch information
santino committed Jul 7, 2023
1 parent 429a2bd commit 58de942
Show file tree
Hide file tree
Showing 5 changed files with 1,522 additions and 1,531 deletions.
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-concurrent-router",
"version": "1.6.0",
"version": "1.6.1",
"description": "Performant routing embracing React concurrent UI patterns",
"author": "Santino Puleio",
"license": "MIT",
Expand Down Expand Up @@ -95,34 +95,35 @@
},
"devDependencies": {
"@ampproject/rollup-plugin-closure-compiler": "^0.27.0",
"@babel/core": "^7.21.4",
"@babel/eslint-parser": "^7.21.3",
"@babel/core": "^7.22.8",
"@babel/eslint-parser": "^7.22.7",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/plugin-transform-object-assign": "^7.18.6",
"@babel/plugin-transform-react-constant-elements": "^7.21.3",
"@babel/plugin-transform-runtime": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@babel/preset-react": "^7.18.6",
"@babel/runtime": "^7.21.0",
"@babel/plugin-transform-object-assign": "^7.22.5",
"@babel/plugin-transform-react-constant-elements": "^7.22.5",
"@babel/plugin-transform-runtime": "^7.22.7",
"@babel/preset-env": "^7.22.7",
"@babel/preset-react": "^7.22.5",
"@babel/runtime": "^7.22.6",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-node-resolve": "^13.3.0",
"@testing-library/dom": "^9.2.0",
"@testing-library/dom": "^9.3.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@types/react": "^18.0.33",
"babel-jest": "^29.5.0",
"@types/react": "^18.2.14",
"babel-jest": "^29.6.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"bundlewatch": "^0.3.3",
"cherry-pick": "^0.5.0",
"coveralls": "^3.1.1",
"cross-env": "^7.0.3",
"doctoc": "^2.2.1",
"dtslint": "^4.2.1",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"lint-staged": "^13.2.0",
"jest": "^29.6.1",
"jest-environment-jsdom": "^29.6.1",
"lint-staged": "^13.2.3",
"open-cli": "^7.2.0",
"prettier-standard": "^16.4.1",
"prop-types": "^15.8.1",
Expand All @@ -131,7 +132,7 @@
"rimraf": "^4.4.1",
"rollup": "^2.79.1",
"rollup-plugin-terser": "^7.0.2",
"standard": "^17.0.0",
"standard": "^17.1.0",
"typescript": "^4.9.5"
},
"peerDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion src/RouteRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ const RouteRenderer = ({ pendingIndicator }) => {
<>
{isPendingEntry && pendingIndicator ? pendingIndicator : null}
<Component
prefetched={routeEntry.prefetched}
key={window.location.href} // force component remount when location changes
params={routeEntry.params}
prefetched={routeEntry.prefetched}
/>
</>
)
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ describe('utils', () => {
location: match.location,
params: match.params,
prefetched: undefined,
assistedPrefetch: false,
assistedPrefetch: false
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export const matchRoutes = (
* when advancing from a pre route warmup to the actual navigation action.
*/
const prepareAssistPrefetchMatch = (
{ route, params, location },
{ params, location },
prefetchToAssist,
awaitPrefetch
) => {
Expand Down
Loading

0 comments on commit 58de942

Please sign in to comment.