diff --git a/src/components/IsUnlocked/index.js b/src/components/IsUnlocked/index.js index 75b96995..13e21ba4 100644 --- a/src/components/IsUnlocked/index.js +++ b/src/components/IsUnlocked/index.js @@ -1,6 +1,6 @@ // @flow -import React, { PureComponent } from 'react' +import React, { Component } from 'react' import { connect } from 'react-redux' import { compose } from 'redux' import { translate } from 'react-i18next' @@ -26,12 +26,12 @@ type InputValue = { } type Props = { - t: T, accounts: Accounts, + children: any, fetchAccounts: Function, isLocked: boolean, - render: Function, settings: Settings, + t: T, unlock: Function, } type State = { @@ -55,7 +55,7 @@ const defaultState = { }, } -class IsUnlocked extends PureComponent { +class IsUnlocked extends Component { state = { ...defaultState, } @@ -76,6 +76,14 @@ class IsUnlocked extends PureComponent { } } + shouldComponentUpdate(nextProps) { + if (nextProps.isLocked) { + return true + } + + return nextProps.children !== this.props.children + } + handleChangeInput = (key: $Keys) => (value: $Values) => this.setState(prev => ({ inputValue: { @@ -111,7 +119,7 @@ class IsUnlocked extends PureComponent { render() { const { inputValue } = this.state - const { isLocked, render, t } = this.props + const { isLocked, t } = this.props if (isLocked) { return ( @@ -132,7 +140,7 @@ class IsUnlocked extends PureComponent { ) } - return render() + return this.props.children } } diff --git a/src/components/TransactionsList/index.js b/src/components/TransactionsList/index.js index 52d26f4d..4cf502e4 100644 --- a/src/components/TransactionsList/index.js +++ b/src/components/TransactionsList/index.js @@ -5,6 +5,7 @@ import styled from 'styled-components' import moment from 'moment' import get from 'lodash/get' +import Defer from 'components/base/Defer' import Box from 'components/base/Box' import Text from 'components/base/Text' @@ -81,7 +82,11 @@ const Transaction = ({ tx }: { tx: TransactionType }) => { ) } -export default ({ transactions }: { transactions: Array }) => ( +type Props = { + transactions: Array, +} + +export default ({ transactions }: Props) => ( {'Date'} @@ -90,6 +95,8 @@ export default ({ transactions }: { transactions: Array }) => ( {'Amount'} - {transactions.map(t => )} + + {transactions.map(t => )} + ) diff --git a/src/components/Wrapper.js b/src/components/Wrapper.js index 1a4ca6d8..d065417f 100644 --- a/src/components/Wrapper.js +++ b/src/components/Wrapper.js @@ -25,31 +25,27 @@ class Wrapper extends Component<{}> { {process.platform === 'darwin' && } - ( - - {__DEV__ && } - - {Object.entries(modals).map(([name, ModalComponent]: [string, any]) => ( - - ))} - - - - - - - - - - - - - - - - )} - /> + + {__DEV__ && } + + {Object.entries(modals).map(([name, ModalComponent]: [string, any]) => ( + + ))} + + + + + + + + + + + + + + + ) } diff --git a/src/components/base/Defer.js b/src/components/base/Defer.js new file mode 100644 index 00000000..f7ddab7e --- /dev/null +++ b/src/components/base/Defer.js @@ -0,0 +1,38 @@ +// @flow + +import { PureComponent } from 'react' + +type Props = { + children: any, +} + +type State = { + show: boolean, +} + +class Defer extends PureComponent { + state = { + show: false, + } + + componentDidMount() { + window.requestAnimationFrame(() => + this.setState({ + show: true, + }), + ) + } + + render() { + const { children } = this.props + const { show } = this.state + + if (show) { + return children + } + + return null + } +} + +export default Defer diff --git a/src/components/base/Modal/index.js b/src/components/base/Modal/index.js index e3fc6c3e..3c1e19cf 100644 --- a/src/components/base/Modal/index.js +++ b/src/components/base/Modal/index.js @@ -4,7 +4,7 @@ /* eslint-disable jsx-a11y/no-static-element-interactions */ /* eslint-disable react/no-multi-comp */ -import React, { Component, PureComponent } from 'react' +import React, { Component } from 'react' import { findDOMNode } from 'react-dom' import { connect } from 'react-redux' import Mortal from 'react-mortal' @@ -18,6 +18,7 @@ import { closeModal, isModalOpened, getModalData } from 'reducers/modals' import Box, { Tabbable } from 'components/base/Box' import GrowScroll from 'components/base/GrowScroll' import Icon from 'components/base/Icon' +import Defer from 'components/base/Defer' type Props = { isOpened?: boolean, @@ -117,11 +118,11 @@ class Pure extends Component { render() { const { data, onClose, render } = this.props - return render({ data, onClose }) + return {render({ data, onClose })} } } -export class Modal extends PureComponent { +export class Modal extends Component { static defaultProps = { data: undefined, isOpened: false, @@ -130,6 +131,14 @@ export class Modal extends PureComponent { preventBackdropClick: false, } + shouldComponentUpdate(nextProps: Props) { + if (this.props.isOpened || nextProps.isOpened) { + return true + } + + return false + } + componentDidUpdate(prevProps: Props) { const didOpened = this.props.isOpened && !prevProps.isOpened const didClose = !this.props.isOpened && prevProps.isOpened @@ -171,12 +180,18 @@ export class Modal extends PureComponent { {(m, isVisible, isAnimated) => ( - + e.stopPropagation()} innerRef={n => (this._wrapper = n)} + onClick={e => e.stopPropagation()} > diff --git a/src/styles/global.js b/src/styles/global.js index 23c17d5e..467c4f05 100644 --- a/src/styles/global.js +++ b/src/styles/global.js @@ -43,6 +43,13 @@ injectGlobal` font-style: italic; } + .scroll-content { + height: 100%; + + > div { + height: 100%; + } + } .scrollbar-thumb { background: rgb(102, 102, 102) !important; padding: 2px;