From f3873351114ae43bc0b9666c1216a478a031f59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Tue, 11 Feb 2025 16:37:08 +0800 Subject: [PATCH] revert: ref back of func --- src/CSSMotion.tsx | 8 ++++---- tests/StrictMode.spec.tsx | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/CSSMotion.tsx b/src/CSSMotion.tsx index d1243bd..84fd72b 100644 --- a/src/CSSMotion.tsx +++ b/src/CSSMotion.tsx @@ -18,8 +18,8 @@ import { getTransitionName, supportTransition } from './util/motion'; export interface CSSMotionRef { nativeElement: HTMLElement; - inMotion: boolean; - enableMotion: boolean; + inMotion: () => boolean; + enableMotion: () => boolean; } export type CSSMotionConfig = @@ -173,11 +173,11 @@ export function genCSSMotion(config: CSSMotionConfig) { }, inMotion: { enumerable: true, - get: () => getStatus() !== STATUS_NONE, + get: () => () => getStatus() !== STATUS_NONE, }, enableMotion: { enumerable: true, - get: () => supportMotion, + get: () => () => supportMotion, }, }); return obj; diff --git a/tests/StrictMode.spec.tsx b/tests/StrictMode.spec.tsx index 0790e1c..2891a8b 100644 --- a/tests/StrictMode.spec.tsx +++ b/tests/StrictMode.spec.tsx @@ -43,7 +43,7 @@ describe('StrictMode', () => { , ); - expect(ref.current.enableMotion).toBeTruthy(); + expect(ref.current.enableMotion()).toBeTruthy(); const node = container.querySelector('.motion-box'); expect(node).toHaveClass('transition-appear', 'transition-appear-start'); @@ -52,7 +52,7 @@ describe('StrictMode', () => { act(() => { jest.runAllTimers(); }); - expect(ref.current.inMotion).toBeTruthy(); + expect(ref.current.inMotion()).toBeTruthy(); expect(node).not.toHaveClass('transition-appear-start'); expect(node).toHaveClass('transition-appear-active'); @@ -60,7 +60,7 @@ describe('StrictMode', () => { fireEvent.transitionEnd(node); expect(node).not.toHaveClass('transition-appear'); - expect(ref.current.inMotion).toBeFalsy(); + expect(ref.current.inMotion()).toBeFalsy(); expect(ref.current.nativeElement).toBe(node); }); });