Skip to content

Refactor routing to use useNavigate and fix redirect paths - #99

Open
Mahesh7741 wants to merge 1 commit into
meabhisingh:masterfrom
Mahesh7741:fix-redirect-paths
Open

Mahesh7741 wants to merge 1 commit into
meabhisingh:masterfrom
Mahesh7741:fix-redirect-paths

Conversation

@Mahesh7741

Copy link
Copy Markdown

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