Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noTimeTravelDebugging prop #455

Merged
merged 2 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ declare module 'connected-react-router' {
history: History<S>;
context?: React.Context<ReactReduxContextValue>;
noInitialPop?: boolean;
noTimeTravelDebugging?: boolean;
omitRouter?: boolean;
}

Expand Down
9 changes: 9 additions & 0 deletions src/ConnectedRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ const createConnectedRouter = (structure) => {

// Subscribe to store changes to check if we are in time travelling
this.unsubscribe = store.subscribe(() => {
// Allow time travel debugging compatibility to be turned off
// as the detection for this (below) is error prone in apps where the
// store may be unmounted, a navigation occurs, and then the store is re-mounted
// during the app's lifetime. Detection could be much improved if Redux DevTools
// simply set a global variable like `REDUX_DEVTOOLS_IS_TIME_TRAVELLING=true`.
const isTimeTravelDebuggingAllowed = !props.noTimeTravelDebugging

// Extract store's location
const {
pathname: pathnameInStore,
Expand All @@ -42,6 +49,7 @@ const createConnectedRouter = (structure) => {

// If we do time travelling, the location in store is changed but location in history is not changed
if (
isTimeTravelDebuggingAllowed &&
props.history.action === 'PUSH' &&
(pathnameInHistory !== pathnameInStore ||
searchInHistory !== searchInStore ||
Expand Down Expand Up @@ -118,6 +126,7 @@ const createConnectedRouter = (structure) => {
children: PropTypes.oneOfType([ PropTypes.func, PropTypes.node ]),
onLocationChanged: PropTypes.func.isRequired,
noInitialPop: PropTypes.bool,
noTimeTravelDebugging: PropTypes.bool,
stateCompareFunction: PropTypes.func,
omitRouter: PropTypes.bool,
}
Expand Down