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

Add "omitRouter" option #421

Merged
merged 2 commits into from
Sep 12, 2020
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 @@ -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.

blackarctic marked this conversation as resolved.
Show resolved Hide resolved
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