From f905991b5473a59af8525b9b70a0db0542fdc9fd Mon Sep 17 00:00:00 2001 From: zthomas Date: Fri, 29 Apr 2016 09:36:52 -0700 Subject: [PATCH] use the latest handler pass in by the props Since the shouldComponentUpdate only checks content and config, if you change an event handler, the component will still be using the previous old handler. A simple fix would be to just always get the latest handler from the props to call instead of using the one stored in the closure. Just a suggestion, but it is a bug that I had to address in production. --- lib/components/TinyMCE.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/components/TinyMCE.js b/lib/components/TinyMCE.js index eb778e9..3302c93 100644 --- a/lib/components/TinyMCE.js +++ b/lib/components/TinyMCE.js @@ -105,10 +105,11 @@ const TinyMCE = React.createClass({ config.selector = '#' + this.id; config.setup = (editor) => { EVENTS.forEach((event, index) => { - const handler = this.props[HANDLER_NAMES[index]]; - if (typeof handler !== 'function') return; + if (!this.props[HANDLER_NAMES[index]]) return; editor.on(event, (e) => { // native DOM events don't have access to the editor so we pass it here + const handler = this.props[HANDLER_NAMES[index]]; + if (typeof handler !== 'function') return; handler(e, editor); }); });