From 41edd8317ca36d8aaed72c5ac0fd7aaac09c7631 Mon Sep 17 00:00:00 2001 From: zeppi Date: Fri, 5 Nov 2021 15:09:06 -0400 Subject: [PATCH] update pagination if page param changes --- ui/component/common/paginate.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/component/common/paginate.jsx b/ui/component/common/paginate.jsx index dc1a8c67f..6d321a5b0 100644 --- a/ui/component/common/paginate.jsx +++ b/ui/component/common/paginate.jsx @@ -20,7 +20,8 @@ function Paginate(props: Props) { const { search } = location; const [textValue, setTextValue] = React.useState(''); const urlParams = new URLSearchParams(search); - const initialPage = disableHistory ? 1 : Number(urlParams.get(PAGINATE_PARAM)) || 1; + const urlParamPage = Number(urlParams.get(PAGINATE_PARAM)); + const initialPage = disableHistory ? 1 : urlParamPage || 1; const [currentPage, setCurrentPage] = React.useState(initialPage); const isMobile = useIsMobile(); @@ -47,6 +48,12 @@ function Paginate(props: Props) { } } + React.useEffect(() => { + if (urlParamPage) { + setCurrentPage(urlParamPage); + } + }, [urlParamPage, setCurrentPage]); + return ( // Hide the paginate controls if we are loading or there is only one page // It should still be rendered to trigger the onPageChange callback