diff --git a/app/App.jsx b/app/App.jsx index d3d79e29..7e856831 100644 --- a/app/App.jsx +++ b/app/App.jsx @@ -1,5 +1,5 @@ // Libs -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; const ipc = require('electron').ipcRenderer; @@ -19,7 +19,7 @@ import AppUpdate from './components/layout/AppUpdate'; import { AppWrapper } from './components/shared/Layout'; // Components -class App extends Component { +class App extends PureComponent { constructor(props) { super(props); this.changeTab = this.changeTab.bind(this); @@ -65,10 +65,6 @@ class App extends Component { }); } - shouldComponentUpdate(nextProps) { - return this.props !== nextProps; - } - componentWillUnmount() { ipc.removeAllListeners([ 'menu-change-tab', diff --git a/app/components/contacts/Contact.jsx b/app/components/contacts/Contact.jsx index ff03e9ec..1f47de50 100644 --- a/app/components/contacts/Contact.jsx +++ b/app/components/contacts/Contact.jsx @@ -1,5 +1,5 @@ // Libs -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; // Custom Components @@ -7,17 +7,13 @@ import { TR, TD } from '../shared/Table'; import Button from '../shared/Button'; // Component -class Contact extends Component { +class Contact extends PureComponent { constructor(props) { super(props); this.deleteContact = this.deleteContact.bind(this); this.newInvoice = this.newInvoice.bind(this); } - shouldComponentUpdate(nextProps) { - return this.props !== nextProps; - } - newInvoice() { const { newInvoice, contact } = this.props; newInvoice(contact); diff --git a/app/components/form/ItemsList.jsx b/app/components/form/ItemsList.jsx index c33c1929..0baf84c6 100644 --- a/app/components/form/ItemsList.jsx +++ b/app/components/form/ItemsList.jsx @@ -1,5 +1,5 @@ // Libs -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; // Redux @@ -58,7 +58,7 @@ const ItemsListDiv = styled.div` `; // Component -export class ItemsList extends Component { +export class ItemsList extends PureComponent { componentDidMount() { const { rows, boundActionCreators } = this.props; if (!rows.length) { @@ -66,10 +66,6 @@ export class ItemsList extends Component { } } - shouldComponentUpdate(nextProps) { - return this.props !== nextProps; - } - render() { // Bound Actions const { addItem, removeItem, updateItem } = this.props.boundActionCreators; diff --git a/app/components/form/Settings.jsx b/app/components/form/Settings.jsx index 6e743a6e..66c170ca 100644 --- a/app/components/form/Settings.jsx +++ b/app/components/form/Settings.jsx @@ -1,5 +1,5 @@ // Libraries -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { isEqual } from 'lodash'; @@ -79,7 +79,7 @@ import Switch from '../shared/Switch'; // Component -class Settings extends Component { +class Settings extends PureComponent { constructor(props) { super(props); this.isSettingsSaved = this.isSettingsSaved.bind(this); @@ -87,10 +87,6 @@ class Settings extends Component { this.handleInputChange = this.handleInputChange.bind(this); } - shouldComponentUpdate(nextProps) { - return this.props !== nextProps; - } - // Update local state handleInputChange(event) { this.props.toggleField(event.target.name); diff --git a/app/components/form/hoc/_withDragNDrop.jsx b/app/components/form/hoc/_withDragNDrop.jsx index a10fd145..9cfe4597 100644 --- a/app/components/form/hoc/_withDragNDrop.jsx +++ b/app/components/form/hoc/_withDragNDrop.jsx @@ -1,16 +1,14 @@ // Libs -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { DragDropContext, Droppable } from 'react-beautiful-dnd'; -class DragNDrop extends Component { +class DragNDrop extends PureComponent { constructor(props) { super(props); this.onDragEnd = this.onDragEnd.bind(this); } - shouldComponentUpdate(nextProps) { - return this.props !== nextProps; - } + onDragEnd(result) { if (!result.destination) { return; diff --git a/app/containers/Contacts.jsx b/app/containers/Contacts.jsx index 2b02e9c3..46cff4ae 100644 --- a/app/containers/Contacts.jsx +++ b/app/containers/Contacts.jsx @@ -1,5 +1,5 @@ // Libs -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { compose } from 'recompose'; import { connect } from 'react-redux'; @@ -26,7 +26,7 @@ import { import { getContacts } from '../reducers/ContactsReducer'; // Component -class Contacts extends Component { +class Contacts extends PureComponent { constructor(props) { super(props); this.newInvoice = this.newInvoice.bind(this); @@ -41,10 +41,6 @@ class Contacts extends Component { }); } - shouldComponentUpdate(nextProps) { - return this.props !== nextProps; - } - componentWillUnmount() { ipc.removeAllListeners('confirmed-delete-contact'); } diff --git a/app/containers/Invoices.jsx b/app/containers/Invoices.jsx index 68862a4e..379c3766 100644 --- a/app/containers/Invoices.jsx +++ b/app/containers/Invoices.jsx @@ -1,5 +1,5 @@ // Libs -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { compose } from 'recompose'; import { connect } from 'react-redux'; @@ -24,7 +24,7 @@ import { PageContent, } from '../components/shared/Layout'; -class Invoices extends Component { +class Invoices extends PureComponent { constructor(props) { super(props); this.deleteInvoice = this.deleteInvoice.bind(this); @@ -41,11 +41,6 @@ class Invoices extends Component { }); } - // Optimization - shouldComponentUpdate(nextProps) { - return this.props !== nextProps; - } - // Remove all IPC listeners when unmounted componentWillUnmount() { ipc.removeAllListeners('confirmed-delete-invoice'); diff --git a/preview/components/main/Invoice.jsx b/preview/components/main/Invoice.jsx index 472d3d50..215044ac 100644 --- a/preview/components/main/Invoice.jsx +++ b/preview/components/main/Invoice.jsx @@ -1,5 +1,5 @@ // Libraries -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; // Style @@ -25,10 +25,7 @@ import Minimal from '../../templates/minimal'; import Business from '../../templates/business'; // Component -class Invoice extends Component { - shouldComponentUpdate(nextProps) { - return this.props !== nextProps; - } +class Invoice extends PureComponent { renderTemplate() { switch (this.props.configs.template) { diff --git a/preview/components/sidebar/AccentColor.jsx b/preview/components/sidebar/AccentColor.jsx index 373d62fe..3cd8f8b2 100644 --- a/preview/components/sidebar/AccentColor.jsx +++ b/preview/components/sidebar/AccentColor.jsx @@ -1,5 +1,5 @@ // Libs -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { BlockPicker } from 'react-color'; import { Section, Label } from '../shared'; @@ -48,7 +48,7 @@ const Cover = styled.div` left: 0px; `; -class AccentColor extends Component { +class AccentColor extends PureComponent { constructor(props) { super(props); this.state = { @@ -63,10 +63,6 @@ class AccentColor extends Component { this.handleInputChange = this.handleInputChange.bind(this); } - shouldComponentUpdate(nextProps, nextState) { - return this.state !== nextState || this.props !== nextProps; - } - handleClick() { this.setState({ showPicker: !this.state.showPicker }); } diff --git a/preview/containers/MainContent.jsx b/preview/containers/MainContent.jsx index 1c34e75d..3d98843b 100644 --- a/preview/containers/MainContent.jsx +++ b/preview/containers/MainContent.jsx @@ -1,5 +1,5 @@ // Libs -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; const ipc = require('electron').ipcRenderer; @@ -35,7 +35,7 @@ const Message = styled.p` // Components import Invoice from '../components/main/Invoice'; -class MainContent extends Component { +class MainContent extends PureComponent { componentDidMount() { ipc.on('update-preview', (event, invoiceData) => { const { dispatch } = this.props; @@ -43,10 +43,6 @@ class MainContent extends Component { }); } - shouldComponentUpdate(nextProps) { - return this.props !== nextProps; - } - componentWillUnmount() { ipc.removeAllListeners(['update-preview']); } diff --git a/preview/containers/SideBar.jsx b/preview/containers/SideBar.jsx index 151383f4..9ac103c6 100644 --- a/preview/containers/SideBar.jsx +++ b/preview/containers/SideBar.jsx @@ -1,5 +1,5 @@ // Libs -import React, { Component } from 'react'; +import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; const ipc = require('electron').ipcRenderer; @@ -35,7 +35,7 @@ import Toggler from '../components/sidebar/Toggler'; import AccentColor from '../components/sidebar/AccentColor'; import Actions from '../components/sidebar/Actions'; -class SideBar extends Component { +class SideBar extends PureComponent { constructor(props) { super(props); this.savePDF = this.savePDF.bind(this); @@ -44,10 +44,6 @@ class SideBar extends Component { this.updateConfigs = this.updateConfigs.bind(this); } - shouldComponentUpdate(nextProps) { - return this.props !== nextProps; - } - handleInputChange(event) { const target = event.target; const value = target.type === 'checkbox' ? target.checked : target.value;