summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiovanni Gonzaga <giovanni@buildo.io>2017-06-27 20:40:22 +0200
committerGitHub <noreply@github.com>2017-06-27 20:40:22 +0200
commita511f7b90a1d8ed4d6ae5390c603210409e3fe08 (patch)
tree322001ac183487fc187c613eda0db3b99894211e
parent5969169ee08b4d75a86f05eb6eaffe3cbf98e0fa (diff)
parent7d1001e2deef2fa5c91306ebea128ec4176c79f7 (diff)
downloadreact-autosize-textarea-a511f7b90a1d8ed4d6ae5390c603210409e3fe08.zip
react-autosize-textarea-a511f7b90a1d8ed4d6ae5390c603210409e3fe08.tar.gz
react-autosize-textarea-a511f7b90a1d8ed4d6ae5390c603210409e3fe08.tar.bz2
Merge pull request #55 from buildo/54-thisdispatcheventupdate_called_too_often
#54: `this.dispatchEvent(UPDATE)` called too often (closes #54)
-rw-r--r--src/TextareaAutosize.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/TextareaAutosize.js b/src/TextareaAutosize.js
index 4abaec7..e6c518e 100644
--- a/src/TextareaAutosize.js
+++ b/src/TextareaAutosize.js
@@ -65,6 +65,7 @@ export default class TextareaAutosize extends React.Component {
}
onChange = e => {
+ this.currentValue = e.target.value;
this.props.onChange && this.props.onChange(e);
}
@@ -104,8 +105,8 @@ export default class TextareaAutosize extends React.Component {
);
}
- componentDidUpdate(prevProps) {
- if (this.getValue(prevProps) !== this.getValue(this.props)) {
+ componentDidUpdate() {
+ if (this.getValue(this.props) !== this.currentValue) {
this.dispatchEvent(UPDATE);
}
}