rc-switch is an unstyled, highly customizable switch (toggle) UI component for React applications, providing fundamental functionality without imposing visual opinions. The package provided here, `rc-switch`, reached its last major release at version 4.1.0. Since then, development and new features have continued under a new scoped package name, `@rc-component/switch`, which currently stands at version 1.0.3. This library is part of the `react-component` ecosystem, known for delivering foundational, barebones UI elements designed for maximum stylistic flexibility. It emphasizes broad browser compatibility and a minimal bundle size, making it suitable for integration into custom design systems. Releases for the original `rc-switch` package have ceased, with all active development now occurring in its successor package, `@rc-component/switch`.
npm install rc-switchVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of the Switch component, including state management for controlled usage and custom styling.
Migrate your project to use `@rc-component/switch`. This typically involves changing `import` paths and potentially updating styling or prop usage if there were minor breaking changes in the transition, though the core API is largely compatible.
Review the changelog for v4.0.0. If you have custom CSS targeting internal elements, you might need to adjust selectors. New props like `checkedChildren` and `unCheckedChildren` provide content slots for the switch's inner labels.
Upgrade `rc-switch` to version `3.2.2` or higher to ensure full compatibility with React 17+. For projects on newer React versions (18+), it is highly recommended to use `@rc-component/switch`.
Ensure `rc-switch` is correctly installed (`npm install rc-switch` or `yarn add rc-switch`). If you intended to use the newer package, install `@rc-component/switch` instead (`npm install @rc-component/switch`) and update your import statements accordingly.
Ensure your project's React version meets the peer dependency requirements (>=16.9.0). Verify that `rc-switch` is being used within a valid React functional component or class component render method, and that your build setup correctly handles React's rendering lifecycle.
If using class components, ensure event handlers are bound correctly (e.g., using arrow functions or binding in the constructor). For functional components, always use the `useState` setter function provided by the hook, and avoid directly mutating state.