use pure component

This commit is contained in:
ryan
2019-03-06 15:54:19 -08:00
parent 627a32e9bb
commit 2e8dd19636

View File

@@ -1,4 +1,4 @@
import React, { Component } from 'react'; import React, { PureComponent } from 'react';
import Remarkable from 'remarkable'; import Remarkable from 'remarkable';
import { sanitize } from 'app/core/utils/text'; import { sanitize } from 'app/core/utils/text';
@@ -14,7 +14,7 @@ interface State {
html: string; html: string;
} }
export class TextPanel extends Component<Props, State> { export class TextPanel extends PureComponent<Props, State> {
remarkable: Remarkable; remarkable: Remarkable;
constructor(props) { constructor(props) {
@@ -30,11 +30,11 @@ export class TextPanel extends Component<Props, State> {
if (html !== this.state.html) { if (html !== this.state.html) {
this.setState({ html }); this.setState({ html });
} }
}, 100); }, 150);
componentDidUpdate(prevProps: Props) { componentDidUpdate(prevProps: Props) {
// Since any change could be referenced in a template variable, // Since any change could be referenced in a template variable,
// This needs to process everything // This needs to process everytime (with debounce)
this.updateHTML(); this.updateHTML();
} }