rc-collapse is a foundational React UI component for creating collapsible panels and accordions. This package, at version 4.0.0, is effectively the final major release under the `rc-collapse` name. Development and active maintenance have since transitioned to the `@rc-component/collapse` package, which continues to evolve the component's features and API. While `rc-collapse@4.0.0` is stable and functional for its specified React peer dependencies (`>=16.9.0`), new features, bug fixes, and long-term support are primarily focused on the successor package. It provides basic collapse functionality with options for accordion mode, custom expand icons, and panel content destruction, but its API for defining panels via `Collapse.Panel` components is superseded by an `items` prop in the newer `@rc-component/collapse` package.
npm install rc-collapseVerified import paths — ran on the pinned version, not inferred.
Demonstrates a basic multi-panel collapse component with initial active state, change handler, and importing necessary styles. Shows deprecated `Panel` component usage as `items` prop was not fully introduced until the successor package.
Migrate your package dependency from `rc-collapse` to `@rc-component/collapse`. Review the changelogs for `@rc-component/collapse` as there may be API changes (e.g., the introduction of the `items` prop). Check the official repository for the latest migration guide if available.
For new development or when migrating to `@rc-component/collapse`, use the `items` prop instead of `Collapse.Panel` children. For example: `<Collapse items={[{ key: '1', label: 'Panel Header', children: 'Panel Content' }]} />`.Ensure you add `import 'rc-collapse/assets/index.css';` to your application's entry point or a relevant component file.
Use `import Collapse from 'rc-collapse';` for the main component. Access the Panel via `const { Panel } = Collapse;`.Ensure `Collapse` is imported as a default export: `import Collapse from 'rc-collapse';` and then access `Panel` as a property: `const { Panel } = Collapse;`Add `import 'rc-collapse/assets/index.css';` to your main application file or the component using `rc-collapse`.
Ensure every `<Panel>` component has a unique and stable `key` prop, e.g., `<Panel key="1" header="Panel 1">...</Panel>`.