rc-motion is a React library designed to provide granular control over component entry, exit, and update animations by leveraging React's lifecycle methods. It enables developers to integrate CSS transition classes or custom JavaScript animation callbacks to manage the visual state of components as they appear, enter, leave, or disappear from the DOM. The package, at version 2.9.5, offers a robust set of features for orchestrating complex animation sequences and serves as a foundational component within the Ant Design ecosystem. Its API, centered around properties like `motionName`, `visible`, and comprehensive lifecycle callbacks (`onAppearStart`, `onEnterEnd`, etc.), emphasizes precise control over animation flow. However, developers should be aware that this specific package (`rc-motion`) has been superseded by `@rc-component/motion` (v1.x), which represents its actively maintained and developed successor.
npm install rc-motionVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of CSSMotion with state-driven visibility, custom motion classes, and lifecycle callbacks.
Consider migrating to `@rc-component/motion` for continued support and updates. Be aware of potential API differences during migration, though core functionality is largely similar.
Update your package dependencies from `rc-motion` to `@rc-component/motion` and review its changelog for any breaking changes introduced in its 1.x releases.
Ensure `removeOnLeave` prop is set to `true`. If issues persist, consider updating to `@rc-component/motion` which has addressed these types of bugs.
Ensure that any child component receiving a ref is either a class component or a functional component wrapped with `React.forwardRef`. If using an older `rc-motion` version, this might require manual ref handling or migrating to `@rc-component/motion` for the fixes.
Use a named import: `import { CSSMotion } from 'rc-motion';`Wrap the child functional component with `React.forwardRef` to allow it to correctly receive and forward refs.
Set the `removeOnLeave` prop on `CSSMotion` to `true`. If the issue persists with `rc-motion@2.9.5`, consider migrating to `@rc-component/motion`.
Ensure your render prop looks like `{({ className, style }) => <div className={className} style={style} />}` to correctly apply the motion styles.