From 90ec1d3ac54d117ec4cdf0be7998618057812cf2 Mon Sep 17 00:00:00 2001 From: Martin Kluska Date: Wed, 25 Oct 2017 22:02:50 +0200 Subject: [PATCH] Setup width/height state when new props are received When changing size (first 200x300) and then changing it to different value (300x200) the render is rendering size correctly, but when starting to drag a corner, the size is changed back to 200x300 until I move mouse. This is caused by different size in state. --- src/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/index.js b/src/index.js index 0aa822dd..a9639c76 100644 --- a/src/index.js +++ b/src/index.js @@ -242,6 +242,13 @@ export default class Resizable extends React.Component { componentWillReceiveProps(next: ResizableProps) { this.updateExtendsProps(next); + + const prevSize = this.props.size; + if (next.size && (typeof prevSize === 'undefined' || + next.size.width !== prevSize.width || + next.size.height !== prevSize.height)) { + this.setState(next.size); + } } componentWillUnmount() {