From 0c544634a27ef93ef9686bd8f32652fd4925afe8 Mon Sep 17 00:00:00 2001 From: dyh_a Date: Tue, 12 Dec 2023 16:30:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(components/popover):=20=E5=9C=A8=20react=20?= =?UTF-8?q?=E4=B8=A5=E6=A0=BC=E6=A8=A1=E5=BC=8F=E4=B8=8B=20trigger=20?= =?UTF-8?q?=E4=B8=BA=20hover=20=E6=97=B6=20RxJs=20=E4=BC=9A=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/popover/hooks/useShowController.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/components/src/popover/hooks/useShowController.ts b/packages/components/src/popover/hooks/useShowController.ts index 6fc49758..241c636d 100644 --- a/packages/components/src/popover/hooks/useShowController.ts +++ b/packages/components/src/popover/hooks/useShowController.ts @@ -12,8 +12,8 @@ import { tap, of, } from 'rxjs'; -import { useBeforeDestroy, fromOuterEvent, useNextEffect } from '@pkg/shared'; import { PopoverRequiredPartProps } from '~/popover/Popover'; +import { fromOuterEvent, useNextEffect } from '@pkg/shared'; import React, { useEffect, useState, useRef } from 'react'; import { castArray, emptyFn } from '@tool-pack/basic'; import { collectScroller } from '@tool-pack/dom'; @@ -88,10 +88,14 @@ export function useShowController( const nextEffect = useNextEffect(); const leaveBalloonSubject = useRef(new Subject()); const enterBalloonSubject = useRef(new Subject()); - useBeforeDestroy(() => { - leaveBalloonSubject.current.unsubscribe(); - enterBalloonSubject.current.unsubscribe(); - }); + useEffect(() => { + const enter = (enterBalloonSubject.current = new Subject()); + const leave = (leaveBalloonSubject.current = new Subject()); + return () => { + enter.unsubscribe(); + leave.unsubscribe(); + }; + }, []); // 事件触发启动 useEffect(() => {