Skip to content

Commit d3683f3

Browse files
committed
chore(changelog): prepare for 3.0.0
1 parent e4a7bc4 commit d3683f3

File tree

3 files changed

+76
-16
lines changed

3 files changed

+76
-16
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
### 3.0.0 (May 10, 2021)
4+
5+
#### Breaking
6+
- Fixed handling of the `nodeRef` that needs to be passed to `<DraggableCore>` to avoid use of ReactDOM. This means that vanilla usage of `react-resizable` no longer requires ReactDOM. No code changes are needed in the usual case, except:
7+
* React `>= 16.3` is required due to use of `React.createRef()`, and
8+
* The `handle` prop now sends a `ReactRef<HTMLElement>` as its second argument and expects it to be used on your returned component.
9+
* If you do not attach the `ref`, you will receive the following error: `"<DraggableCore> not mounted on DragStart!"` This is due to the ref being present but not attached to any node.
10+
311
### 1.11.1 (Mar 5, 2021)
412

513
- Added React 17 to peerDependencies.

README.md

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,72 @@ See the [demo](/examples/TestLayout.js) for more on this.
1717

1818
### Installation
1919

20-
Using [npm](https://www.npmjs.com/):
21-
2220
$ npm install --save react-resizable
2321

22+
### Compatibility
23+
24+
[React-Resizable 3.x](/CHANGELOG.md#3.0.0) is compatible with React `>= 16.3`.
25+
React-Resizable 2.x has been skipped.
26+
[React-Resizable 1.x](/CHANGELOG.md#1.11.1) is compatible with React `14-17`.
27+
2428
### Usage
2529

30+
This package has two major exports:
31+
32+
* [`<Resizable>`](/lib/Resizable.js): A raw component that does not have state. Use as a building block for larger components, by listening to its
33+
callbacks and setting its props.
34+
* [`<ResizableBox>`](/lib/ResizableBox.js): A simple `<div {...props} />` element that manages basic state. Convenient for simple use-cases.
35+
36+
37+
#### `<Resizable>`
2638
```js
27-
const Resizable = require('react-resizable').Resizable; // or,
28-
const ResizableBox = require('react-resizable').ResizableBox;
39+
const {Resizable} = require('react-resizable');
2940

3041
// ES6
31-
import { Resizable, ResizableBox } from 'react-resizable';
42+
import { Resizable } from 'react-resizable';
3243

3344
// ...
34-
render() {
35-
return (
36-
<ResizableBox width={200} height={200} draggableOpts={{...}}
37-
minConstraints={[100, 100]} maxConstraints={[300, 300]}>
38-
<span>Contents</span>
39-
</ResizableBox>
40-
);
45+
class Example extends React.Component {
46+
state = {
47+
width: 200,
48+
height: 200,
49+
};
50+
51+
// On top layout
52+
onResize = (event, {element, size, handle}) => {
53+
this.setState({width: size.width, height: size.height});
54+
};
55+
56+
render() {
57+
return (
58+
<Resizable height={this.state.height} width={this.state.width} onResize={this.onResize}>
59+
<div className="box" style={{width: this.state.width + 'px', height: this.state.height + 'px'}}>
60+
<span>Contents</span>
61+
</div>
62+
</Resizable>
63+
);
64+
}
65+
}
66+
67+
```
68+
69+
70+
#### `<ResizableBox>`
71+
```js
72+
const {ResizableBox} = require('react-resizable');
73+
74+
// ES6
75+
import { ResizableBox } from 'react-resizable';
76+
77+
class Example extends React.Component {
78+
render() {
79+
return (
80+
<ResizableBox width={200} height={200} draggableOpts={{...}}
81+
minConstraints={[100, 100]} maxConstraints={[300, 300]}>
82+
<span>Contents</span>
83+
</ResizableBox>
84+
);
85+
}
4186
}
4287
```
4388

@@ -46,12 +91,20 @@ render() {
4691
These props apply to both `<Resizable>` and `<ResizableBox>`. Unknown props that are not in the list below will be passed to the child component.
4792

4893
```js
94+
type ResizeCallbackData = {
95+
node: HTMLElement,
96+
size: {width: number, height: number},
97+
handle: ResizeHandleAxis
98+
};
99+
type ResizeHandleAxis = 's' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne';
100+
101+
type ResizableProps =
49102
{
50103
children: React.Element<any>,
51104
width: number,
52105
height: number,
53106
// Either a ReactElement to be used as handle, or a function returning an element that is fed the handle's location as its first argument.
54-
handle: ReactElement<any> | (resizeHandle: 's' | 'w' | 'e' | 'n' | 'sw' | 'nw' | 'se' | 'ne') => ReactElement<any>,
107+
handle: ReactElement<any> | (resizeHandle: ResizeHandleAxis, ref: ReactRef<HTMLElement>) => ReactElement<any>,
55108
// If you change this, be sure to update your css
56109
handleSize: [number, number] = [10, 10],
57110
lockAspectRatio: boolean = false,
@@ -70,7 +123,7 @@ The following props can also be used on `<ResizableBox>`:
70123
71124
```js
72125
{
73-
style?: Object
126+
style?: Object // styles the returned <div />
74127
}
75128
```
76129

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@
6666
"react-draggable": "^4.0.3"
6767
},
6868
"peerDependencies": {
69-
"react": "0.14.x || 15.x || 16.x || 17.x",
70-
"react-dom": "0.14.x || 15.x || 16.x || 17.x"
69+
"react": ">= 16.3"
7170
},
7271
"publishConfig": {
7372
"registry": "https://registry.npmjs.org"

0 commit comments

Comments
 (0)