summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancesco Cioria <firefelix@gmail.com>2017-06-27 20:21:58 +0200
committerFrancesco Cioria <firefelix@gmail.com>2017-06-27 20:21:58 +0200
commit7d1001e2deef2fa5c91306ebea128ec4176c79f7 (patch)
tree322001ac183487fc187c613eda0db3b99894211e
parent5969169ee08b4d75a86f05eb6eaffe3cbf98e0fa (diff)
downloadreact-autosize-textarea-7d1001e2deef2fa5c91306ebea128ec4176c79f7.zip
react-autosize-textarea-7d1001e2deef2fa5c91306ebea128ec4176c79f7.tar.gz
react-autosize-textarea-7d1001e2deef2fa5c91306ebea128ec4176c79f7.tar.bz2
dispatch UPDATE event only if props.value !== currentValue
-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);
}
}