Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
Remove unnecessary shouldComponentUpdate (MetaMask#7875)
Browse files Browse the repository at this point in the history
The `confirm-seed-phrase` component extends PureComponent, so it
doesn't need a `shouldComponentUpdate` function. The state is
effectively immutable, as all state is either a primitive type or is
updated with new instances rather than mutation.

Removing this function will silence a warning message printed to the
console during e2e tests (React doesn't want you to set this function
on `PureComponent`s).

Removing this function also exposed an unused piece of state, which has
also been removed.
  • Loading branch information
Gudahtt authored and yqrashawn committed Feb 3, 2020
1 parent 6817de3 commit dfd6b78
Showing 1 changed file with 0 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,6 @@ export default class ConfirmSeedPhrase extends PureComponent {
pendingSeedIndices: [],
draggingSeedIndex: -1,
hoveringIndex: -1,
isDragging: false,
}

shouldComponentUpdate (nextProps, nextState) {
const { seedPhrase } = this.props
const {
selectedSeedIndices,
shuffledSeedWords,
pendingSeedIndices,
draggingSeedIndex,
hoveringIndex,
isDragging,
} = this.state

return (
seedPhrase !== nextProps.seedPhrase ||
draggingSeedIndex !== nextState.draggingSeedIndex ||
isDragging !== nextState.isDragging ||
hoveringIndex !== nextState.hoveringIndex ||
selectedSeedIndices.join(' ') !==
nextState.selectedSeedIndices.join(' ') ||
shuffledSeedWords.join(' ') !== nextState.shuffledSeedWords.join(' ') ||
pendingSeedIndices.join(' ') !== nextState.pendingSeedIndices.join(' ')
)
}

componentDidMount () {
Expand Down

0 comments on commit dfd6b78

Please sign in to comment.