fix: notification render error & remove SWR auto load on focus

This commit is contained in:
haitao(lj) 2022-09-28 15:06:56 +08:00
parent 2031b76ee5
commit a95ef9a477
2 changed files with 16 additions and 7 deletions

View File

@ -3,6 +3,8 @@ import { useTranslation } from 'react-i18next';
import { Outlet } from 'react-router-dom'; import { Outlet } from 'react-router-dom';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { SWRConfig } from 'swr';
import { import {
userInfoStore, userInfoStore,
siteInfoStore, siteInfoStore,
@ -51,13 +53,18 @@ const Layout: FC = () => {
<meta name="description" content={siteInfo.description} /> <meta name="description" content={siteInfo.description} />
) : null} ) : null}
</Helmet> </Helmet>
<Header /> <SWRConfig
<AdminHeader /> value={{
<div className="position-relative page-wrap"> revalidateOnFocus: false,
<Outlet /> }}>
</div> <Header />
<Toast msg={toastMsg} variant={variant} onClose={closeToast} /> <AdminHeader />
<Footer /> <div className="position-relative page-wrap">
<Outlet />
</div>
<Toast msg={toastMsg} variant={variant} onClose={closeToast} />
<Footer />
</SWRConfig>
</> </>
); );
}; };

View File

@ -46,6 +46,8 @@ const Notifications = () => {
const handleTypeChange = (evt, val) => { const handleTypeChange = (evt, val) => {
evt.preventDefault(); evt.preventDefault();
setPage(1);
setNotificationData([]);
navigate(`/users/notifications/${val}`); navigate(`/users/notifications/${val}`);
}; };