react-split is a React component that enables the creation of resizable split views in web applications. It functions as a lightweight, declarative wrapper around the core Split.js library. Developers define child components within a `<Split>` container, which are then rendered as resizable panes. The current stable version is 2.0.14, with an active release cadence focused on bug fixes and minor feature enhancements. Its primary strengths include ease of use, minimal overhead, and direct exposure of Split.js options via React props, allowing for straightforward integration of flexible, resizable layouts. The package also ships with full TypeScript type definitions.
npm install react-splitVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up a basic horizontal split view using `react-split` with two child components. It includes various configuration options like initial `sizes`, `minSize`, `gutterSize`, and event handlers for drag start/end, along with basic styling for visual clarity.
Ensure your React version is compatible. If encountering unexpected behavior, verify that children passed to `<Split>` are standard React elements or fragments.
Upgrade to `react-split@>=1.5.7` to benefit from fixes. Always ensure `minSize` is set to a reasonable pixel value and `sizes` array values respect this minimum.
Update to `react-split@>=1.5.9`. If the issue persists, consider conditionally mounting the `<Split>` component only when it is visible, or manually triggering a resize when its container becomes visible.
Upgrade to `react-split@>=1.5.6` to ensure consistent and correct cursor behavior as expected.
If supporting mobile, ensure you upgrade to `react-split@>=1.5.5` to resolve the mobile dragging issues introduced in the previous patch.
Set a robust `minSize` prop (e.g., `minSize={50}`) and ensure initial `sizes` are valid. Upgrade to `react-split@>=1.5.7` to benefit from fixes related to low `sizes` values.Update to `react-split@>=1.5.9`. Alternatively, ensure the component is visible upon mounting, or trigger a re-render/resize operation when the container becomes visible.
Correct the import statement to use the default import: `import Split from 'react-split'`.
Use `import type { SplitProps } from 'react-split'` for importing the type definition.