Skip to content

Commit

Permalink
fix: handle pr
Browse files Browse the repository at this point in the history
  • Loading branch information
Yilun-Sun committed Nov 7, 2022
1 parent 69fe878 commit 6282def
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/guide/Guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import useConfig from '../hooks/useConfig';
import Popup from '../popup';
import { GuideCrossProps, StepPopupPlacement, TdGuideProps } from './type';
import { addClass, removeClass, isFixed, getWindowScroll } from '../_util/dom';
import { scrollToParentVisibleArea, getRelativePosition, getTargetElm, scrollToElm, useWatch } from './utils';
import { scrollToParentVisibleArea, getRelativePosition, getTargetElm, scrollToElm } from './utils';
import setStyle from '../_common/js/utils/set-style';
import useControlled from '../hooks/useControlled';
import { guideDefaultProps } from './defaultProps';
Expand Down Expand Up @@ -173,24 +173,26 @@ const Guide = (props: GuideProps) => {
}
};

useWatch(innerCurrent, (newValue) => {
if (newValue >= 0 && newValue < steps.length) {
useEffect(() => {
if (innerCurrent >= 0 && innerCurrent < steps.length) {
initGuide();
} else {
setActive(false);
destroyGuide();
}
});

const useMount = (callback) => {
useEffect(() => {
callback();
}, [callback]);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [innerCurrent]);

useMount(() => {
useEffect(() => {
initGuide();
});
console.log('init');

return () => {
destroyGuide();
console.log('destroy');
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const renderOverlayLayer = () =>
createPortal(
Expand Down

0 comments on commit 6282def

Please sign in to comment.