From 5c9ad9675bc4bf616584a31135b8cebceeca5ca8 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Tue, 13 Mar 2018 16:07:09 +0100 Subject: [PATCH] Refactor send component to have less state --- src/components/send/index.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/components/send/index.js b/src/components/send/index.js index e35a5876449..890a880b5d5 100644 --- a/src/components/send/index.js +++ b/src/components/send/index.js @@ -15,20 +15,13 @@ import styles from './send.css'; class Send extends React.Component { constructor(props) { super(props); - const { address, amount } = parseSearchParams(props.history.location.search); this.state = { - address, - amount, - sendIsActive: !!address, + sendIsActive: !!this.getSearchParams().address || !!this.getSearchParams().amount, }; } - componentWillReceiveProps(nextProps) { - const { address, amount } = parseSearchParams(nextProps.history.location); - - if (address !== this.state.address || amount !== this.state.amount) { - this.setState({ address, amount }); - } + getSearchParams() { + return parseSearchParams(this.props.history.location.search); } setSendIsActive(sendIsActive) { @@ -54,8 +47,8 @@ class Send extends React.Component { className={styles.wrapper}> breakpoints.m} - address={this.state.address} - amount={this.state.amount} + address={this.getSearchParams().address} + amount={this.getSearchParams().amount} />