fix(core): page mode switch sometimes not working (#5306)

Should not pass inline object without memo into `InternalLottie`.
cdc96876b0/packages/frontend/component/src/components/internal-lottie/index.tsx (L77)

In the detail page when during syncing on the cloud, the detail page will be re-rendered constantly because of `useCurrentSyncEngineStatus` hook, which will then cause `PageSwitchItem` to re-render and forcing the internal lottie state to reset. As a result the click event may not be captured somehow.
This commit is contained in:
Peng Xiao
2023-12-15 08:21:41 +00:00
parent fe2851d3e9
commit fc56a53acd
2 changed files with 23 additions and 22 deletions

View File

@@ -14,6 +14,7 @@ import { useWorkspaceStatus } from '@toeverything/hooks/use-workspace-status';
import { appSettingAtom, currentPageIdAtom } from '@toeverything/infra/atom';
import { useAtomValue, useSetAtom } from 'jotai';
import {
memo,
type ReactElement,
type ReactNode,
useCallback,
@@ -101,7 +102,7 @@ const DetailPageLayout = ({
);
};
const DetailPageImpl = ({ page }: { page: Page }) => {
const DetailPageImpl = memo(function DetailPageImpl({ page }: { page: Page }) {
const currentPageId = page.id;
const { openPage, jumpToSubPath } = useNavigateHelper();
const currentWorkspace = useAtomValue(waitForCurrentWorkspaceAtom);
@@ -200,7 +201,7 @@ const DetailPageImpl = ({ page }: { page: Page }) => {
<GlobalPageHistoryModal />
</>
);
};
});
const useForceUpdate = () => {
const [, setCount] = useState(0);