-
Notifications
You must be signed in to change notification settings - Fork 34
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 createMatchSelector function from connected-react-router #55
base: master
Are you sure you want to change the base?
add createMatchSelector function from connected-react-router #55
Conversation
Hi, thanks for this PR! Some points I'd like to care about:
|
let lastMatch: match<{}> | null = null; | ||
return (state: any) => { | ||
const { pathname } = state.router.location ?? {}; | ||
if (pathname === lastPathname) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use selectRouterState
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for response!
Usage of selectRouterState function - done
Separated folder - it's a specially react-router function that use "matchPath" from react-router
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it apply only to react router v5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v5 and v6, used function exists in both
https://v5.reactrouter.com/web/api/matchPath
https://reactrouter.com/docs/en/v6/api#matchpath
routerReducerKey?: string; | ||
} | ||
|
||
export const createMatchSelector = (path: string, options?: Options) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signature should also allow an array of strings (as the connected-react-router
signature does)
export const createMatchSelector = (path: string, options?: Options) => { | |
export const createMatchSelector = (path: string | string[], options?: Options) => { |
for those who used createMatchSelector function from connected-react-router