diff --git a/src/CSSMotion.tsx b/src/CSSMotion.tsx index dca6c0b..f0c468c 100644 --- a/src/CSSMotion.tsx +++ b/src/CSSMotion.tsx @@ -163,7 +163,7 @@ export function genCSSMotion(config: CSSMotionConfig) { } // ====================== Refs ====================== - const [refObj] = React.useState(() => { + const refObj = React.useMemo(() => { const obj = {} as CSSMotionRef; Object.defineProperties(obj, { nativeElement: { @@ -178,7 +178,7 @@ export function genCSSMotion(config: CSSMotionConfig) { }, }); return obj; - }); + }, []); // We lock `deps` here since function return object // will repeat trigger ref from `refConfig` -> `null` -> `refConfig`