-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove React Router's useNavigate dependency (#1270)
**Related Ticket:** Contributes to #1108 This aims to ensure catalog filters work correctly in Next.js. ### Description of Changes Removes the usage of React Router's `useNavigate` hook in the library to make it more agnostic of routing frameworks, allowing it to work better with Next.js instances. Changes included: - Added a custom `commit` function to `useQsStateCreator`. It appears this was the only place where the `useNavigate` function was effectively in use. I tried using the default `commit` function from the [qs-state-hook](https://github.com/danielfdsilva/qs-state-hook) library, but it doesn't work with Next.js - Formatted the touched files ### Validation / Testing Using `veda-config`: 1. Visit the data catalog page 2. Click on filters, and URL params are updated as usual 3. Reload the page with filters selected; the filter panel is populated as expected 4. Repeat the steps on the Exploration and Stories pages Using `next-veda-ui` instance: 1. Link the source of this PR to the Next.js instance using the instructions in `veda-ui/docs/development/REGISTRY.md` 2. Replace the file `app/(datasets)/data-catalog/catalog.tsx` (this avoids build errors caused by type issues) ```js 'use client'; import React from 'react'; import { CatalogView, useFiltersWithQS } from '@lib'; import { usePathname } from 'next/navigation'; import Link from 'next/link'; export default function Catalog({ datasets }: { datasets: any }) { const pathname = usePathname(); const controlVars = useFiltersWithQS(); return ( <CatalogView datasets={datasets} onFilterChanges={() => controlVars} pathname={pathname} linkProperties={{ LinkElement: Link, pathAttributeKeyName: 'href', }} /> ); } ``` 3. Access `http://localhost:3000/data-catalog`. Filter changes are reflected in the URL, and reloading populates the filter panel as expected This is ready for review.
- Loading branch information
Showing
4 changed files
with
55 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters