Skip to content

Commit

Permalink
Migrate away from deprecated componentWillReceiveProps
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelbej committed Mar 26, 2020
1 parent c1ec014 commit d1fda09
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 25 deletions.
7 changes: 4 additions & 3 deletions client/src/views/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class Account extends React.Component {
this.loadData(address);
}

componentWillReceiveProps(nextProps) {
const { address } = nextProps.match.params;
if (address !== this.state.address) {
componentDidUpdate(prevProps) {
const { address: prevAddress } = prevProps.match.params;
const { address } = this.props.match.params;
if (prevAddress !== address) {
this.loadData(address);
}
}
Expand Down
7 changes: 4 additions & 3 deletions client/src/views/BlockInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ class BlockInfo extends React.Component {
this.loadData(hash);
}

componentWillReceiveProps(nextProps) {
const { hash } = nextProps.match.params;
if (this.state.hash !== hash) {
componentDidUpdate(prevProps) {
const { hash: prevHash } = prevProps.match.params;
const { hash } = this.props.match.params;
if (prevHash !== hash) {
this.loadData(hash);
}
}
Expand Down
11 changes: 6 additions & 5 deletions client/src/views/BlockList.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ class BlockList extends React.Component {
setTimeout(this.refreshEvents, BLOCKLIST_REFRESH_TIMEOUT * 1000);
}

componentWillReceiveProps(nextProps) {
const { start, count } = parseParams(nextProps);
if (!this.state.data || this.state.data.start !== start ||
this.state.data.count !== count) {
this.loadData(start, count);
componentDidUpdate(prevProps) {
const { start: prevStart, count: prevCount } = parseParams(prevProps);
const { start, count } = parseParams(this.props);
if (prevStart !== start
|| prevCount !== count) {
this.loadData(start, count);
}
}

Expand Down
13 changes: 7 additions & 6 deletions client/src/views/BlockTxList.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ class BlockTxList extends React.Component {
this.loadData(hash, start, count);
}

componentWillReceiveProps(nextProps) {
const { hash, start, count } = parseParams(nextProps);
if (this.state.hash !== hash ||
this.state.start !== start ||
this.state.count !== count) {
this.loadData(hash, start, count);
componentDidUpdate(prevProps) {
const { hash: prevHash, start: prevStart, count: prevCount } = parseParams(prevProps);
const { hash, start, count } = parseParams(this.props);
if (prevHash !== hash
|| prevStart !== start
|| prevCount !== count) {
this.loadData(hash, start, count);
}
}

Expand Down
7 changes: 4 additions & 3 deletions client/src/views/TxInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ class TxInfo extends React.Component {
this.loadData(hash);
}

componentWillReceiveProps(nextProps) {
const { hash } = nextProps.match.params;
if (hash !== this.state.hash) {
componentDidUpdate(prevProps) {
const { hash: prevHash } = prevProps.match.params;
const { hash } = this.props.match.params;
if (prevHash !== hash) {
this.loadData(hash);
}
}
Expand Down
11 changes: 6 additions & 5 deletions client/src/views/TxList.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ class TxList extends React.Component {
this.loadData(start, count);
}

componentWillReceiveProps(nextProps) {
const { start, count } = parseParams(nextProps);
if (!this.state.data || this.state.data.start !== start ||
this.state.data.count !== count) {
this.loadData(start, count);
componentDidUpdate(prevProps) {
const { start: prevStart, count: prevCount } = parseParams(prevProps);
const { start, count } = parseParams(this.props);
if (prevStart !== start
|| prevCount !== count) {
this.loadData(start, count);
}
}

Expand Down

0 comments on commit d1fda09

Please sign in to comment.