Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Call update (if necessary) when props change
Browse files Browse the repository at this point in the history
  • Loading branch information
osahyoun committed Apr 5, 2018
1 parent c918169 commit 4b168b0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/javascript/components/EmailEditor/EmailEditor.js
@@ -1,10 +1,10 @@
// @flow
import React, { PureComponent } from 'react';
import React, { Component } from 'react';
import Input from '../SweetInput/SweetInput';
import FormGroup from '../Form/FormGroup';
import ErrorMessages from '../ErrorMessages';
import { FormattedMessage } from 'react-intl';
import { compact, get, template } from 'lodash';
import { compact, get, template, isEqual } from 'lodash';
import classnames from 'classnames';
import type { ErrorMap } from '../../util/ChampaignClient/Base';
import './EmailEditor.scss';
Expand All @@ -24,7 +24,7 @@ type Props = {
onUpdate: (email: EmailProps) => void,
};

export default class EmailEditor extends PureComponent {
export default class EmailEditor extends Component {
props: Props;
state: EmailProps;
constructor(props: Props) {
Expand All @@ -39,6 +39,14 @@ export default class EmailEditor extends PureComponent {
this.update();
}

componentDidUpdate() {
this.update();
}

shouldComponentUpdate(nextProps: Props) {
return !isEqual(nextProps, this.props);
}

body() {
return compact([
this.parse(this.props.header),
Expand Down

0 comments on commit 4b168b0

Please sign in to comment.