Replacing the depreciated useHistory() hook with the new useNavigate() hook #1452
+8
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates the navigation logic to align with React Router v6, replacing the deprecated useHistory() hook with the new useNavigate() hook. React Router v6 introduced useNavigate() to simplify programmatic navigation and remove the legacy useHistory() API. This change ensures the application works seamlessly with React Router v6.
Changes include:
Replaced useHistory() with useNavigate() in the Tutorials component and relevant functions.
Updated navigation calls from history.push() to navigate() for navigating to tutorial pages and selecting tags.
Refactored handleContainerClick and selectTag to use navigate() for URL updates and navigation. This change ensures the codebase is compatible with the latest version of React Router, improving readability and future-proofing.