From 4c8baddd26d95e6dbb80144b0e00abd413a96b15 Mon Sep 17 00:00:00 2001 From: laixingyou Date: Wed, 10 Apr 2024 11:02:08 +0800 Subject: [PATCH] feat:add search (#343) Signed-off-by: laixingyou --- apps/web/src/modules/collection/MainContent.tsx | 4 +++- apps/web/src/modules/collection/MainHeader.tsx | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/web/src/modules/collection/MainContent.tsx b/apps/web/src/modules/collection/MainContent.tsx index 82d12201..d40ec2e2 100644 --- a/apps/web/src/modules/collection/MainContent.tsx +++ b/apps/web/src/modules/collection/MainContent.tsx @@ -122,7 +122,9 @@ const MainContent = ({ const [keyword, setKeyword] = useState(''); const [sort, setSort] = useState(''); - + useEffect(() => { + setKeyword(''); + }, [slug, router]); const params = { ident: slug, page: 1, diff --git a/apps/web/src/modules/collection/MainHeader.tsx b/apps/web/src/modules/collection/MainHeader.tsx index 87ac0f25..13d0341f 100644 --- a/apps/web/src/modules/collection/MainHeader.tsx +++ b/apps/web/src/modules/collection/MainHeader.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { useRouter } from 'next/router'; import { useTranslation } from 'next-i18next'; import { Collection } from '@modules/explore/type'; @@ -39,7 +39,9 @@ const MainHeader = ({ }); const collection = ident ? collectionsMap[ident] : null; const [value, setValue] = useState(keyword); - + useEffect(() => { + setValue(''); + }, [ident]); useHotkeys( 'enter', (e, he) => {