diff --git a/index.d.ts b/index.d.ts index 4d5b5770..b42721a6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -18,6 +18,7 @@ declare module 'connected-react-router' { history: History; context?: React.Context; noInitialPop?: boolean; + omitRouter?: boolean; } export type RouterActionType = Action; diff --git a/package.json b/package.json index a8932f70..b74397fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "connected-react-router", - "version": "6.8.0", + "version": "6.8.1", "description": "A Redux binding for React Router v4 and v5", "main": "lib/index.js", "module": "esm/index.js", diff --git a/src/ConnectedRouter.js b/src/ConnectedRouter.js index a2957634..401925bd 100644 --- a/src/ConnectedRouter.js +++ b/src/ConnectedRouter.js @@ -85,7 +85,15 @@ const createConnectedRouter = (structure) => { } render() { - const { history, children } = this.props + const { omitRouter, history, children } = this.props + + // The `omitRouter` option is available for applications that must + // have a Router instance higher in the component tree but still desire + // to use connected-react-router for its Redux integration. + + if (omitRouter) { + return <>{ children } + } return ( @@ -111,6 +119,7 @@ const createConnectedRouter = (structure) => { onLocationChanged: PropTypes.func.isRequired, noInitialPop: PropTypes.bool, stateCompareFunction: PropTypes.func, + omitRouter: PropTypes.bool, } const mapDispatchToProps = dispatch => ({