Skip to content

Commit

Permalink
Refactor send component to have less state
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Mar 13, 2018
1 parent 7235ec0 commit 5c9ad96
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/components/send/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -54,8 +47,8 @@ class Send extends React.Component {
className={styles.wrapper}>
<SendWritable
autoFocus={this.state.sendIsActive || window.innerWidth > breakpoints.m}
address={this.state.address}
amount={this.state.amount}
address={this.getSearchParams().address}
amount={this.getSearchParams().amount}
/>
<PassphraseSteps />
<SendReadable />
Expand Down

0 comments on commit 5c9ad96

Please sign in to comment.