summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--karma.conf.js2
-rw-r--r--src/TextareaAutosize.js16
2 files changed, 7 insertions, 11 deletions
diff --git a/karma.conf.js b/karma.conf.js
index d6ea1eb..daf05e6 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -46,7 +46,7 @@ module.exports = function (config) {
loaders: [
{
test: /\.jsx?$/,
- loader: 'babel?stage=0&loose',
+ loader: 'babel',
include: [paths.SRC, paths.TEST],
exclude: /node_modules/
}
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);
}
}