Skip to content

Commit

Permalink
chore: useMemo instead
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Feb 11, 2025
1 parent bb9dda7 commit 39399ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/CSSMotion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export function genCSSMotion(config: CSSMotionConfig) {
}

// ====================== Refs ======================
const [refObj] = React.useState<CSSMotionRef>(() => {
const refObj = React.useMemo<CSSMotionRef>(() => {
const obj = {} as CSSMotionRef;
Object.defineProperties(obj, {
nativeElement: {
Expand All @@ -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`
Expand Down

0 comments on commit 39399ec

Please sign in to comment.