add comments

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/5995/head
Michael Telatynski 2018-01-23 20:28:39 +00:00
parent 9d1a3c9011
commit 22b7298542
1 changed files with 4 additions and 0 deletions

View File

@ -30,10 +30,14 @@ export default class SyntaxHighlight extends React.Component {
this._ref = this._ref.bind(this); this._ref = this._ref.bind(this);
} }
// componentDidUpdate used here for reusability
// componentWillReceiveProps fires too early to call highlightBlock on.
componentDidUpdate() { componentDidUpdate() {
if (this._el) highlightBlock(this._el); if (this._el) highlightBlock(this._el);
} }
// call componentDidUpdate because _ref is fired on initial render
// which does not fire componentDidUpdate
_ref(el) { _ref(el) {
this._el = el; this._el = el;
this.componentDidUpdate(); this.componentDidUpdate();