当 spring 项目离开 DOM 时,什么也没有发生(没有离开动画)。
完整的 CodeSandbox:https ://codesandbox.io/s/jzz6xv1y4w
const Todo = ({ todo, onDeleteClick }) => {
const transition = useTransition(todo, null, {
from: { opacity: 0, transform: "translateY(-10px)" },
enter: { opacity: 1, transform: "translateY(0)" },
leave: { opacity: 0, transform: "translateY(10px)" }
});
return transition.map(
({ item, props, key }) =>
item && (
<TodoContainer style={props} key={key}>
<span>{todo}</span>
<button onClick={onDeleteClick}>X</button>
</TodoContainer>
)
);
};