From 6459f754d3899f5fe1688614fcccfee518d12c89 Mon Sep 17 00:00:00 2001 From: tennen Date: Sat, 2 Feb 2019 15:14:16 +0800 Subject: [PATCH] fix componentUpdate causes same code to be highlighted multiple times and make highlightjs create useless span --- src/index.js | 2 +- src/optimized.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 7c204c0..042836f 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import hljs from 'highlight.js'; import React from 'react'; -class Highlight extends React.Component { +class Highlight extends React.PureComponent { constructor(props) { super(props) this.setEl = this.setEl.bind(this) diff --git a/src/optimized.js b/src/optimized.js index e97f670..c45a321 100644 --- a/src/optimized.js +++ b/src/optimized.js @@ -1,7 +1,7 @@ import hljs from'highlight.js/lib/highlight'; import React from'react'; -class Highlight extends React.Component { +class Highlight extends React.PureComponent { componentDidMount() { this.highlightCode(); }