Skip to content

Commit c1626a2

Browse files
authored
docs: add v2.x migration section to migration guide (#864)
Update the migration guide to include a dedicated section for v2.x users. v2.x had a different API than v0.1.x (it already used Pane components with initialSize prop), so each version needs its own migration instructions. - Add "Migrating from v2.x" section with specific prop mappings - Keep "Migrating from v0.1.x" section for older users - Document key differences: initialSize→defaultSize, split→direction swap - Update README.md and CHANGELOG.md references Closes #863
1 parent 1f48a4d commit c1626a2

File tree

3 files changed

+109
-25
lines changed

3 files changed

+109
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ All notable changes to this project will be documented in this file. See [standa
3232

3333
### Migration
3434

35-
See [MIGRATION.md](./MIGRATION.md) for detailed upgrade instructions from v0.1.x.
35+
See [MIGRATION.md](./MIGRATION.md) for detailed upgrade instructions from v0.1.x or v2.x.
3636

3737
### [0.1.92](https://github.com/tomkp/react-split-pane/compare/v0.1.91...v0.1.92) (2020-08-10)
3838

MIGRATION.md

Lines changed: 107 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# Migration Guide: v0.1.x to v3.0.0
1+
# Migration Guide to v3.0.0
22

3-
This guide will help you migrate from react-split-pane v0.1.x to v3.0.0. Version 3 is a complete rewrite with modern React patterns, TypeScript support, and improved accessibility.
3+
This guide will help you migrate to react-split-pane v3.0.0. Version 3 is a complete rewrite with modern React patterns, TypeScript support, and improved accessibility.
44

5-
## Overview of Changes
5+
## Migrating from v0.1.x
66

7-
v3.0.0 introduces several breaking changes:
7+
### Overview of Changes
8+
9+
v3.0.0 introduces several breaking changes from v0.1.x:
810

911
- **Component structure**: Children must be wrapped in `<Pane>` components
1012
- **Props renamed**: `split``direction`, callback names changed
@@ -13,9 +15,9 @@ v3.0.0 introduces several breaking changes:
1315
- **New features**: Keyboard navigation, ARIA attributes, touch support, snap points
1416
- **Removed**: `primary` prop, `allowResize` per-pane, `Resizer` class names
1517

16-
## Quick Migration
18+
### Quick Migration
1719

18-
### Before (v0.1.x)
20+
#### Before (v0.1.x)
1921

2022
```jsx
2123
import SplitPane from 'react-split-pane';
@@ -26,7 +28,7 @@ import SplitPane from 'react-split-pane';
2628
</SplitPane>
2729
```
2830

29-
### After (v3)
31+
#### After (v3)
3032

3133
```jsx
3234
import { SplitPane, Pane } from 'react-split-pane';
@@ -41,9 +43,9 @@ import { SplitPane, Pane } from 'react-split-pane';
4143
</SplitPane>
4244
```
4345

44-
## Detailed Changes
46+
### Detailed Changes
4547

46-
### 1. Import Changes
48+
#### 1. Import Changes
4749

4850
```jsx
4951
// v0.1.x
@@ -53,7 +55,7 @@ import SplitPane from 'react-split-pane';
5355
import { SplitPane, Pane } from 'react-split-pane';
5456
```
5557

56-
### 2. Children Must Be Wrapped in `<Pane>`
58+
#### 2. Children Must Be Wrapped in `<Pane>`
5759

5860
In v0.1.x, you could use any element as children. In v3, all children must be `<Pane>` components:
5961

@@ -75,7 +77,7 @@ In v0.1.x, you could use any element as children. In v3, all children must be `<
7577
</SplitPane>
7678
```
7779

78-
### 3. Direction Terminology Changed
80+
#### 3. Direction Terminology Changed
7981

8082
The meaning of `vertical` and `horizontal` has been **swapped** to align with CSS flexbox terminology:
8183

@@ -104,7 +106,7 @@ In v3, `direction` describes the flex direction:
104106
<SplitPane direction="vertical">
105107
```
106108

107-
### 4. Size Props Moved to `<Pane>`
109+
#### 4. Size Props Moved to `<Pane>`
108110

109111
Size constraints have moved from `<SplitPane>` to individual `<Pane>` components:
110112

@@ -126,7 +128,7 @@ Size constraints have moved from `<SplitPane>` to individual `<Pane>` components
126128
</SplitPane>
127129
```
128130

129-
### 5. Size Values Accept Strings
131+
#### 5. Size Values Accept Strings
130132

131133
v3 accepts both numbers (pixels) and strings with units:
132134

@@ -140,7 +142,7 @@ v3 accepts both numbers (pixels) and strings with units:
140142
<Pane minSize="10%" defaultSize="25%"> // percentages
141143
```
142144

143-
### 6. Callback Props Renamed
145+
#### 6. Callback Props Renamed
144146

145147
| v0.1.x | v3 | Notes |
146148
|--------|-----|-------|
@@ -169,7 +171,7 @@ The `ResizeEvent` object includes:
169171
- `source`: `'mouse'` | `'touch'` | `'keyboard'`
170172
- `originalEvent`: The original DOM event
171173

172-
### 7. `primary` Prop Removed
174+
#### 7. `primary` Prop Removed
173175

174176
The `primary` prop has been removed. In v3, sizes are distributed proportionally when the container resizes. For controlled sizing, use the `size` prop on each `<Pane>`:
175177

@@ -190,7 +192,7 @@ function App() {
190192
}
191193
```
192194

193-
### 8. `allowResize` Renamed to `resizable`
195+
#### 8. `allowResize` Renamed to `resizable`
194196

195197
```jsx
196198
// v0.1.x
@@ -200,7 +202,7 @@ function App() {
200202
<SplitPane resizable={false}>
201203
```
202204

203-
### 9. `step` Prop
205+
#### 9. `step` Prop
204206

205207
The `step` prop now applies to keyboard navigation. Use `snapPoints` for drag snapping:
206208

@@ -216,17 +218,17 @@ The `step` prop now applies to keyboard navigation. Use `snapPoints` for drag sn
216218
>
217219
```
218220

219-
### 10. Styling Changes
221+
#### 10. Styling Changes
220222

221-
#### CSS Class Names Changed
223+
##### CSS Class Names Changed
222224

223225
| v0.1.x | v3 |
224226
|--------|-----|
225227
| `SplitPane` | `split-pane` |
226228
| `Resizer` | `split-pane-divider` |
227229
| `Pane1`, `Pane2` | `split-pane-pane` |
228230

229-
#### Inline Style Props Changed
231+
##### Inline Style Props Changed
230232

231233
| v0.1.x | v3 |
232234
|--------|-----|
@@ -262,7 +264,7 @@ The `step` prop now applies to keyboard navigation. Use `snapPoints` for drag sn
262264
</SplitPane>
263265
```
264266

265-
#### Custom Resizer → Custom Divider
267+
##### Custom Resizer → Custom Divider
266268

267269
```jsx
268270
// v0.1.x - CSS class customization
@@ -283,7 +285,7 @@ function CustomDivider(props) {
283285
<SplitPane divider={CustomDivider}>
284286
```
285287

286-
### 11. Persistence Pattern Updated
288+
#### 11. Persistence Pattern Updated
287289

288290
```jsx
289291
// v0.1.x
@@ -311,7 +313,7 @@ function App() {
311313
}
312314
```
313315

314-
### 12. Multiple Panes
316+
#### 12. Multiple Panes
315317

316318
v3 supports 2+ panes natively (no nesting required):
317319

@@ -333,6 +335,88 @@ v3 supports 2+ panes natively (no nesting required):
333335
</SplitPane>
334336
```
335337

338+
---
339+
340+
## Migrating from v2.x
341+
342+
v2.x had a different API than v0.1.x. It already used `<Pane>` components but with different prop names.
343+
344+
### Quick Migration
345+
346+
#### Before (v2.x)
347+
348+
```jsx
349+
import SplitPane from 'react-split-pane';
350+
import Pane from 'react-split-pane/lib/Pane';
351+
352+
<SplitPane split="vertical" onChange={handleChange}>
353+
<Pane initialSize="200px" minSize="100px" maxSize="500px">
354+
<div>Left</div>
355+
</Pane>
356+
<Pane>
357+
<div>Right</div>
358+
</Pane>
359+
</SplitPane>
360+
```
361+
362+
#### After (v3)
363+
364+
```jsx
365+
import { SplitPane, Pane } from 'react-split-pane';
366+
367+
<SplitPane direction="horizontal" onResize={handleChange}>
368+
<Pane defaultSize="200px" minSize="100px" maxSize="500px">
369+
<div>Left</div>
370+
</Pane>
371+
<Pane>
372+
<div>Right</div>
373+
</Pane>
374+
</SplitPane>
375+
```
376+
377+
### Key Differences from v2.x
378+
379+
| v2.x | v3 | Notes |
380+
|------|-----|-------|
381+
| `split="vertical"` | `direction="horizontal"` | Terminology swapped |
382+
| `split="horizontal"` | `direction="vertical"` | Terminology swapped |
383+
| `initialSize` | `defaultSize` | Prop renamed |
384+
| `onChange` | `onResize` | Callback renamed, signature changed |
385+
| `onResizeStart` | `onResizeStart` | Same name, different signature |
386+
| `onResizeEnd` | `onResizeEnd` | Same name, different signature |
387+
| `resizerSize` | N/A | Use CSS to style divider width |
388+
389+
### Import Changes
390+
391+
```jsx
392+
// v2.x
393+
import SplitPane from 'react-split-pane';
394+
import Pane from 'react-split-pane/lib/Pane';
395+
396+
// v3
397+
import { SplitPane, Pane } from 'react-split-pane';
398+
```
399+
400+
### Callback Signature Changes
401+
402+
```jsx
403+
// v2.x
404+
<SplitPane
405+
onChange={(sizes) => console.log(sizes)}
406+
onResizeStart={() => console.log('started')}
407+
onResizeEnd={(sizes) => console.log('ended', sizes)}
408+
>
409+
410+
// v3
411+
<SplitPane
412+
onResize={(sizes, event) => console.log(sizes, event.source)}
413+
onResizeStart={(event) => console.log('started', event.source)}
414+
onResizeEnd={(sizes, event) => console.log('ended', sizes)}
415+
>
416+
```
417+
418+
---
419+
336420
## New Features in v3
337421

338422
### Keyboard Navigation

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ A subtle single-pixel divider:
345345

346346
React Split Pane works seamlessly with Tailwind CSS and shadcn/ui. See [TAILWIND.md](./TAILWIND.md) for detailed integration examples including custom dividers and CSS variable overrides.
347347

348-
## Migration from v0.1.x
348+
## Migration from v0.1.x or v2.x
349349

350350
See [MIGRATION.md](./MIGRATION.md) for detailed migration guide.
351351

0 commit comments

Comments
 (0)