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

Refactor routing to use useNavigate and fix redirect paths #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mahesh7741
Copy link

Title
Refactor Routing to Use useNavigate and Fix Redirect Paths

Description
This pull request refactors the routing implementation in the Cart component to use the useNavigate hook from react-router-dom instead of the deprecated history object. The changes address issues with relative redirect paths and ensure consistency with the current routing practices.

Changes Made:
Replaced history.push with useNavigate in the Cart component.
Updated redirect path in checkoutHandler to use an absolute path (/login?redirect=/shipping) to avoid issues with relative paths.

Why This Change?
The useNavigate hook is the recommended approach for handling navigation in React Router v6 and later. The previous use of history.push was not only outdated but also caused incorrect redirect paths due to relative path handling.

Related Issues:
Issue #98 : Fix incorrect redirect paths in the cart component.
Testing:
Verified that navigation to the login page with a redirect to the shipping page works as expected.
Ensured that the Cart component continues to function correctly with updated routing logic.
Screenshots/GIFs:

Screenshot 2024-09-12 004639

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.

1 participant