-
Notifications
You must be signed in to change notification settings - Fork 0
Feature implementation from commits 7ce106a..f120b09 #3
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
base: feature-base-branch-1
Are you sure you want to change the base?
Conversation
…file Upgrade to GitHub-native Dependabot
Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.21.1 to 2.21.2. - [Release notes](https://github.com/date-fns/date-fns/releases) - [Changelog](https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md) - [Commits](date-fns/date-fns@v2.21.1...v2.21.2) Signed-off-by: dependabot[bot] <support@github.com>
…ate-fns-2.21.2 Bump date-fns from 2.21.1 to 2.21.2
Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.21.2 to 2.21.3. - [Release notes](https://github.com/date-fns/date-fns/releases) - [Changelog](https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md) - [Commits](https://github.com/date-fns/date-fns/commits) Signed-off-by: dependabot[bot] <support@github.com>
…ate-fns-2.21.3 Bump date-fns from 2.21.2 to 2.21.3
Bumps [@testing-library/user-event](https://github.com/testing-library/user-event) from 13.1.8 to 13.1.9. - [Release notes](https://github.com/testing-library/user-event/releases) - [Changelog](https://github.com/testing-library/user-event/blob/master/CHANGELOG.md) - [Commits](testing-library/user-event@v13.1.8...v13.1.9) Signed-off-by: dependabot[bot] <support@github.com>
…esting-library/user-event-13.1.9 Bump @testing-library/user-event from 13.1.8 to 13.1.9
Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 11.2.6 to 11.2.7. - [Release notes](https://github.com/testing-library/react-testing-library/releases) - [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md) - [Commits](testing-library/react-testing-library@v11.2.6...v11.2.7) Signed-off-by: dependabot[bot] <support@github.com>
…esting-library/react-11.2.7 Bump @testing-library/react from 11.2.6 to 11.2.7
Bumps [@stripe/react-stripe-js](https://github.com/stripe/react-stripe-js) from 1.4.0 to 1.4.1. - [Release notes](https://github.com/stripe/react-stripe-js/releases) - [Changelog](https://github.com/stripe/react-stripe-js/blob/master/CHANGELOG.md) - [Commits](stripe/react-stripe-js@v1.4.0...v1.4.1) Signed-off-by: dependabot[bot] <support@github.com>
…tripe/react-stripe-js-1.4.1 Bump @stripe/react-stripe-js from 1.4.0 to 1.4.1
Bumps [@stripe/stripe-js](https://github.com/stripe/stripe-js) from 1.14.0 to 1.15.0. - [Release notes](https://github.com/stripe/stripe-js/releases) - [Commits](stripe/stripe-js@v1.14.0...v1.15.0) Signed-off-by: dependabot[bot] <support@github.com>
…tripe/stripe-js-1.15.0 Bump @stripe/stripe-js from 1.14.0 to 1.15.0
Bumps [date-fns](https://github.com/date-fns/date-fns) from 2.21.3 to 2.22.1. - [Release notes](https://github.com/date-fns/date-fns/releases) - [Changelog](https://github.com/date-fns/date-fns/blob/master/CHANGELOG.md) - [Commits](date-fns/date-fns@v2.21.3...v2.22.1) Signed-off-by: dependabot[bot] <support@github.com>
…ate-fns-2.22.1 Bump date-fns from 2.21.3 to 2.22.1
Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.12.0 to 5.13.0. - [Release notes](https://github.com/testing-library/jest-dom/releases) - [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md) - [Commits](testing-library/jest-dom@v5.12.0...v5.13.0) --- updated-dependencies: - dependency-name: "@testing-library/jest-dom" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
…esting-library/jest-dom-5.13.0 Bump @testing-library/jest-dom from 5.12.0 to 5.13.0
Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.13.0 to 5.14.1. - [Release notes](https://github.com/testing-library/jest-dom/releases) - [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md) - [Commits](testing-library/jest-dom@v5.13.0...v5.14.1) --- updated-dependencies: - dependency-name: "@testing-library/jest-dom" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
…esting-library/jest-dom-5.14.1 Bump @testing-library/jest-dom from 5.13.0 to 5.14.1
Bumps [@stripe/stripe-js](https://github.com/stripe/stripe-js) from 1.15.0 to 1.15.1. - [Release notes](https://github.com/stripe/stripe-js/releases) - [Commits](stripe/stripe-js@v1.15.0...v1.15.1) --- updated-dependencies: - dependency-name: "@stripe/stripe-js" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 11.2.7 to 12.0.0. - [Release notes](https://github.com/testing-library/react-testing-library/releases) - [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md) - [Commits](testing-library/react-testing-library@v11.2.7...v12.0.0) --- updated-dependencies: - dependency-name: "@testing-library/react" dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [react-cropper](https://github.com/react-cropper/react-cropper) from 2.1.7 to 2.1.8. - [Release notes](https://github.com/react-cropper/react-cropper/releases) - [Commits](react-cropper/react-cropper@v2.1.7...v2.1.8) --- updated-dependencies: - dependency-name: react-cropper dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
…eact-cropper-2.1.8 Bump react-cropper from 2.1.7 to 2.1.8
…tripe/stripe-js-1.15.1 Bump @stripe/stripe-js from 1.15.0 to 1.15.1
…esting-library/react-12.0.0 Bump @testing-library/react from 11.2.7 to 12.0.0
useEffect( | ||
() => | ||
history.block( | ||
(location, action) => | ||
action !== "PUSH" || | ||
getLocationId(location) !== getLocationId(history.location) | ||
), | ||
[] // eslint-disable-line react-hooks/exhaustive-deps | ||
); |
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.
🐛 Correctness Issue
Memory Leak: Missing Cleanup Function.
The useEffect hook doesn't return the cleanup function from history.block(), which will cause memory leaks when components unmount.
Current Code (Diff):
- useEffect(
- () =>
- history.block(
- (location, action) =>
- action !== "PUSH" ||
- getLocationId(location) !== getLocationId(history.location)
- ),
- [] // eslint-disable-line react-hooks/exhaustive-deps
- );
+ useEffect(
+ () => {
+ const unblock = history.block(
+ (location, action) =>
+ action !== "PUSH" ||
+ getLocationId(location) !== getLocationId(history.location)
+ );
+ return unblock;
+ },
+ [] // eslint-disable-line react-hooks/exhaustive-deps
+ );
📝 Committable suggestion
‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀
useEffect( | |
() => | |
history.block( | |
(location, action) => | |
action !== "PUSH" || | |
getLocationId(location) !== getLocationId(history.location) | |
), | |
[] // eslint-disable-line react-hooks/exhaustive-deps | |
); | |
useEffect( | |
() => { | |
const unblock = history.block( | |
(location, action) => | |
action !== "PUSH" || | |
getLocationId(location) !== getLocationId(history.location) | |
); | |
return unblock; | |
}, | |
[] // eslint-disable-line react-hooks/exhaustive-deps | |
); |
PR Summary
Add useLocationBlocker Hook to Prevent Duplicate History Entries
Overview
This PR introduces a new custom hook
useLocationBlocker
that prevents React Router from pushing the same page to history multiple times, improving navigation experience by avoiding duplicate history entries.Change Types
Affected Modules
shared/functions/useLocationBlocker.js
logged_in/components/Routing.js
logged_out/components/Routing.js
Notes for Reviewers