Skip to content

Commit

Permalink
fix(ui): fix useMaxIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
xiejay97 committed Mar 15, 2022
1 parent f3cfaac commit 8803c50
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/ui/src/hooks/common/useMaxIndex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useId, useRef } from 'react';
import { useId, useMemo, useRef } from 'react';

import { usePrefixConfig } from '../d-config';
import { useUnmount } from '../lifecycle';
Expand Down Expand Up @@ -27,7 +27,7 @@ export function useMaxIndex(condition: boolean) {
const prevIndex = useRef<string>();
const id = useId();

const zIndex = (() => {
const zIndex = useMemo(() => {
MAX_INDEX_MANAGER.deleteRecord(id);

if (condition) {
Expand All @@ -36,7 +36,7 @@ export function useMaxIndex(condition: boolean) {
}

return prevIndex.current;
})();
}, [condition, dPrefix, id]);
prevIndex.current = zIndex;

useUnmount(() => {
Expand Down

0 comments on commit 8803c50

Please sign in to comment.