Skip to content

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

Open
wants to merge 30 commits into
base: feature-base-branch-1
Choose a base branch
from

Conversation

codeOwlAI
Copy link
Owner

@codeOwlAI codeOwlAI commented Jun 29, 2025

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

Type Description
Enhancement Added a custom hook to improve navigation behavior
Refactor Updated routing components to use the new hook

Affected Modules

Module / File Change Description
shared/functions/useLocationBlocker.js Added new custom hook to prevent duplicate history entries
logged_in/components/Routing.js Implemented useLocationBlocker hook
logged_out/components/Routing.js Implemented useLocationBlocker hook

Notes for Reviewers

  • This change affects navigation behavior by preventing duplicate history entries
  • Improves user experience by avoiding multiple back-button clicks to exit the application

dependabot-preview bot and others added 30 commits April 28, 2021 22:13
…file

Upgrade to GitHub-native Dependabot
…ate-fns-2.21.2

Bump date-fns from 2.21.1 to 2.21.2
…ate-fns-2.21.3

Bump date-fns from 2.21.2 to 2.21.3
…esting-library/user-event-13.1.9

Bump @testing-library/user-event from 13.1.8 to 13.1.9
…esting-library/react-11.2.7

Bump @testing-library/react from 11.2.6 to 11.2.7
…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
…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
Comment on lines +13 to +21
useEffect(
() =>
history.block(
(location, action) =>
action !== "PUSH" ||
getLocationId(location) !== getLocationId(history.location)
),
[] // eslint-disable-line react-hooks/exhaustive-deps
);
Copy link

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! 🚀

Suggested change
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
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants