From a9c68c0d34daf4d865c32e1bc3fdea45f5fb216b Mon Sep 17 00:00:00 2001 From: Dmitry Goryunov Date: Thu, 3 Aug 2017 11:07:10 +0200 Subject: [PATCH 1/2] Call resize() on componentDidMount and on componentDidUpdate, but not on component --- src/ace.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ace.js b/src/ace.js index 5782ea21..b90b351b 100644 --- a/src/ace.js +++ b/src/ace.js @@ -100,6 +100,8 @@ export default class ReactAce extends Component { if (onLoad) { onLoad(this.editor); } + + this.editor.resize(); } componentWillReceiveProps(nextProps) { @@ -174,9 +176,12 @@ export default class ReactAce extends Component { if (nextProps.focus && !oldProps.focus) { this.editor.focus(); } - if(nextProps.height !== this.props.height || nextProps.width !== this.props.width){ - this.editor.resize(); - } + } + + componentDidUpdate(prevProps) { + if(prevProps.height !== this.props.height || prevProps.width !== this.props.width){ + this.editor.resize(); + } } handleScrollMargins(margins = [0, 0, 0, 0]) { From 5e3feb82d10b1dfa2d88e0577edd245b4776df8e Mon Sep 17 00:00:00 2001 From: Dmitry Goryunov Date: Thu, 3 Aug 2017 11:16:59 +0200 Subject: [PATCH 2/2] Repair the identation --- src/ace.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ace.js b/src/ace.js index b90b351b..1d3217fc 100644 --- a/src/ace.js +++ b/src/ace.js @@ -179,9 +179,9 @@ export default class ReactAce extends Component { } componentDidUpdate(prevProps) { - if(prevProps.height !== this.props.height || prevProps.width !== this.props.width){ - this.editor.resize(); - } + if(prevProps.height !== this.props.height || prevProps.width !== this.props.width){ + this.editor.resize(); + } } handleScrollMargins(margins = [0, 0, 0, 0]) {