diff options
author | Gabriele Petronella <gabriele@buildo.io> | 2017-01-22 18:53:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-22 18:53:47 +0100 |
commit | 4266b0abc46d4bc6a624b4e8bf58be9b6322eb27 (patch) | |
tree | 9f71a3b97ef1e557298471d60cd52ff86faaead2 | |
parent | 5d05d9660185e073a7c2d319e28f3710470a6a35 (diff) | |
parent | 1fd376a5b8d22eb3aa7473bae4ef22881110db66 (diff) | |
download | react-autosize-textarea-4266b0abc46d4bc6a624b4e8bf58be9b6322eb27.zip react-autosize-textarea-4266b0abc46d4bc6a624b4e8bf58be9b6322eb27.tar.gz react-autosize-textarea-4266b0abc46d4bc6a624b4e8bf58be9b6322eb27.tar.bz2 |
Merge pull request #28 from buildo/27-getting_a_lot_of
#27: Getting a lot of Null is not an object in production (closes #27)
-rw-r--r-- | karma.conf.js | 2 | ||||
-rw-r--r-- | src/TextareaAutosize.js | 16 |
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); } } |