From ca490d84fff4629bf8902161c3140205396fe4af Mon Sep 17 00:00:00 2001 From: yyh Date: Fri, 26 Dec 2025 17:01:16 +0800 Subject: [PATCH] fix --- web/context/modal-context.tsx | 2 +- web/hooks/use-query-params.spec.tsx | 16 ++++++++-------- web/hooks/use-query-params.ts | 16 +++------------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/web/context/modal-context.tsx b/web/context/modal-context.tsx index 8cdb2e8794..dce7b9f6e1 100644 --- a/web/context/modal-context.tsx +++ b/web/context/modal-context.tsx @@ -157,7 +157,7 @@ export const ModalContextProvider = ({ children, }: ModalContextProviderProps) => { // Use nuqs hooks for URL-based modal state management - const { isOpen: showPricingModal, setIsOpen: setPricingModalOpen } = usePricingModal() + const [showPricingModal, setPricingModalOpen] = usePricingModal() const [urlAccountModalState, setUrlAccountModalState] = useAccountSettingModal() const accountSettingCallbacksRef = useRef, 'payload'> | null>(null) diff --git a/web/hooks/use-query-params.spec.tsx b/web/hooks/use-query-params.spec.tsx index 68692030b3..2aa6b7998f 100644 --- a/web/hooks/use-query-params.spec.tsx +++ b/web/hooks/use-query-params.spec.tsx @@ -37,7 +37,7 @@ describe('useQueryParams hooks', () => { const { result } = renderWithAdapter(() => usePricingModal()) // Act - const { isOpen } = result.current + const [isOpen] = result.current // Assert expect(isOpen).toBe(false) @@ -51,7 +51,7 @@ describe('useQueryParams hooks', () => { ) // Act - const { isOpen } = result.current + const [isOpen] = result.current // Assert expect(isOpen).toBe(true) @@ -65,7 +65,7 @@ describe('useQueryParams hooks', () => { ) // Act - const { isOpen } = result.current + const [isOpen] = result.current // Assert expect(isOpen).toBe(false) @@ -77,7 +77,7 @@ describe('useQueryParams hooks', () => { // Act act(() => { - result.current.setIsOpen(true) + result.current[1](true) }) // Assert @@ -92,7 +92,7 @@ describe('useQueryParams hooks', () => { // Act act(() => { - result.current.setIsOpen(true) + result.current[1](true) }) // Assert @@ -110,7 +110,7 @@ describe('useQueryParams hooks', () => { // Act act(() => { - result.current.setIsOpen(false) + result.current[1](false) }) // Assert @@ -128,7 +128,7 @@ describe('useQueryParams hooks', () => { // Act act(() => { - result.current.setIsOpen(false) + result.current[1](false) }) // Assert @@ -143,7 +143,7 @@ describe('useQueryParams hooks', () => { // Act act(() => { - result.current.setIsOpen(true, { history: 'replace' }) + result.current[1](true, { history: 'replace' }) }) // Assert diff --git a/web/hooks/use-query-params.ts b/web/hooks/use-query-params.ts index 534d2032cd..2e1e38daab 100644 --- a/web/hooks/use-query-params.ts +++ b/web/hooks/use-query-params.ts @@ -13,7 +13,6 @@ * - Use shallow routing to avoid unnecessary re-renders */ -import type { Options } from 'nuqs' import { createParser, parseAsArrayOf, @@ -39,27 +38,18 @@ const parseAsPricingModal = createParser({ /** * Hook to manage pricing modal state via URL - * @returns { isOpen, setIsOpen } - isOpen boolean and setter + * @returns [isOpen, setIsOpen] - Tuple like useState * * @example - * const { isOpen, setIsOpen } = usePricingModal() + * const [isOpen, setIsOpen] = usePricingModal() * setIsOpen(true) // Sets ?pricing=open * setIsOpen(false) // Removes ?pricing */ export function usePricingModal() { - const [isOpen, setIsOpenState] = useQueryState( + return useQueryState( PRICING_MODAL_QUERY_PARAM, parseAsPricingModal, ) - - const setIsOpen = useCallback( - (open: boolean, options?: Options) => { - setIsOpenState(open, options) - }, - [setIsOpenState], - ) - - return { isOpen, setIsOpen } } /**