Skip to content

Commit

Permalink
refactor(components/transition): useTransition内移除多余代码
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxinssfd committed Aug 24, 2023
1 parent b9a4a12 commit c223af2
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/components/src/transition/transition.hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ export function useTransition(
status,
) || !children;

const classes = useMemo(
() => (noTrans ? undefined : getClasses(name, status === STATUS.show)),
[noTrans, name, status],
)!;
const classes = getClasses(name, status === STATUS.show);

if (!children) elRef.current = null;

Expand All @@ -174,17 +171,16 @@ export function useTransition(
// console.log(from, 'status', STATUS[status], !!transRef.current);
if (!el) return;

innerCB?.(el, status, LIFE_CIRCLE.before);
cb?.(el, status, LIFE_CIRCLE.before);
const cbs = [innerCB, cb].filter(Boolean) as CB[];
cbs.forEach((cb) => cb(el, status, LIFE_CIRCLE.before));

if (noTrans) return;

const trans = addTransition({
el,
classes,
on: (lifeCircle) => {
innerCB?.(el, status, lifeCircle);
cb?.(el, status, lifeCircle);
cbs.forEach((cb) => cb(el, status, lifeCircle));
},
});
trans.start();
Expand Down

0 comments on commit c223af2

Please sign in to comment.