Skip to content

Commit

Permalink
fix: null router
Browse files Browse the repository at this point in the history
  • Loading branch information
suemor233 committed Feb 10, 2023
1 parent aae8573 commit 9a74d72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/components/in-page/Home/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ const PostNav = () => {
pathname: '/',
query: item.query
? { ...router.query, ...item.query }
: { category },
: category
? { category }
: '',
}}
shallow
>
Expand All @@ -129,6 +131,7 @@ const PostNav = () => {
export const List = () => {
const [postList, setPostList] = useState<IPostList[]>([])
const router = useRouter()
const [lastRouterName, setLastRouterName] = useState(router.asPath)
const [load, setLoad] = useState(true)
const [hasMore, sethasMore] = useState(true)
const fetchList = async (currentPage: number) => {
Expand All @@ -149,10 +152,13 @@ export const List = () => {
}

useEffect(() => {
setLoad(true)
sethasMore(true)
setPostList([])
fetchList(1)
if (router.asPath != lastRouterName || postList.length == 0) {
setLoad(true)
sethasMore(true)
setPostList([])
fetchList(1)
setLastRouterName(router.asPath)
}
}, [router.query])

return (
Expand Down
1 change: 1 addition & 0 deletions src/components/layouts/BasicLayout/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const TabItem: FC<TabModule> = ({ slug, title, tag }) => {
data-promote={tag?.slice(0, 5)}
href={`${slug?.startsWith('http') ? '' : '/'}${slug || ''}`}
target={slug?.startsWith('http') ? '_blank' : undefined}
shallow
>
{title}
</Link>
Expand Down

1 comment on commit 9a74d72

@vercel
Copy link

@vercel vercel bot commented on 9a74d72 Feb 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

juejin – ./

juejin-xi.vercel.app
juejin-bocchi.vercel.app
juejin-git-master-bocchi.vercel.app

Please sign in to comment.