summaryrefslogtreecommitdiffstats
path: root/src/TextareaAutosize.js
diff options
context:
space:
mode:
authorFrancesco Cioria <firefelix@gmail.com>2017-01-22 17:12:57 +0100
committerFrancesco Cioria <firefelix@gmail.com>2017-01-22 17:12:57 +0100
commit93d5c5cde1053f4ee45c2044b3ba1f717b9ab83c (patch)
treed406668b2f69c003bc998a2d3b574f86f92e1612 /src/TextareaAutosize.js
parent5d05d9660185e073a7c2d319e28f3710470a6a35 (diff)
downloadreact-autosize-textarea-93d5c5cde1053f4ee45c2044b3ba1f717b9ab83c.zip
react-autosize-textarea-93d5c5cde1053f4ee45c2044b3ba1f717b9ab83c.tar.gz
react-autosize-textarea-93d5c5cde1053f4ee45c2044b3ba1f717b9ab83c.tar.bz2
replace CWRP with CDU so to avoid using a "setTimeout" when manually forcing a resize update
Diffstat (limited to 'src/TextareaAutosize.js')
-rw-r--r--src/TextareaAutosize.js16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/TextareaAutosize.js b/src/TextareaAutosize.js
index 7619a03..8677c6a 100644
--- a/src/TextareaAutosize.js
+++ b/src/TextareaAutosize.js
@@ -35,15 +35,11 @@ export default class TextareaAutosize extends React.Component {
this.dispatchEvent(DESTROY);
}
- dispatchEvent = (EVENT_TYPE, defer) => {
+ dispatchEvent = (EVENT_TYPE) => {
const event = document.createEvent('Event');
event.initEvent(EVENT_TYPE, true, false);
- const dispatch = () => this.textarea.dispatchEvent(event);
- if (defer) {
- setTimeout(dispatch);
- } else {
- dispatch();
- }
+
+ this.textarea.dispatchEvent(event);
};
getValue = ({ valueLink, value }) => valueLink ? valueLink.value : value;
@@ -57,9 +53,9 @@ export default class TextareaAutosize extends React.Component {
);
}
- componentWillReceiveProps(nextProps) {
- if (this.getValue(nextProps) !== this.getValue(this.props)) {
- this.dispatchEvent(UPDATE, true);
+ componentDidUpdate(prevProps) {
+ if (this.getValue(prevProps) !== this.getValue(this.props)) {
+ this.dispatchEvent(UPDATE);
}
}