Skip to content

Commit

Permalink
Add "omitRouter" option (#421)
Browse files Browse the repository at this point in the history
* Add "omitRouter" option
  • Loading branch information
blackarctic committed Sep 12, 2020
1 parent afb7ee6 commit f10b162
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ declare module 'connected-react-router' {
history: History<S>;
context?: React.Context<ReactReduxContextValue>;
noInitialPop?: boolean;
omitRouter?: boolean;
}

export type RouterActionType = Action;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 10 additions & 1 deletion src/ConnectedRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Router history={history}>
Expand All @@ -111,6 +119,7 @@ const createConnectedRouter = (structure) => {
onLocationChanged: PropTypes.func.isRequired,
noInitialPop: PropTypes.bool,
stateCompareFunction: PropTypes.func,
omitRouter: PropTypes.bool,
}

const mapDispatchToProps = dispatch => ({
Expand Down

0 comments on commit f10b162

Please sign in to comment.