Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
perf: don't re-render SeedConfirm on mount
Browse files Browse the repository at this point in the history
Fix #2792
  • Loading branch information
mrfelton committed Nov 6, 2019
1 parent cc86755 commit b9a54e2
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions renderer/components/Onboarding/Steps/SeedConfirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,26 @@ import { Bar, Header, Span } from 'components/UI'
import { Form, Input, Label } from 'components/Form'
import messages from './messages'

/**
* genIndices - Generate a random selection of seed word indexes.
*
* @param {number} qty Number of indexes to generate
* @returns {Array} Array of random seed indexes
*/
const genIndices = qty => {
const seedWordIndexes = []
while (seedWordIndexes.length < qty) {
const r = Math.floor(Math.random() * 24) + 1
if (seedWordIndexes.indexOf(r) === -1) {
seedWordIndexes.push(r)
}
}
return seedWordIndexes
}

class SeedConfirm extends React.Component {
state = {
seedWordIndexes: [],
seedWordIndexes: genIndices(3),
}

static propTypes = {
Expand All @@ -24,21 +41,6 @@ class SeedConfirm extends React.Component {
wizardState: {},
}

componentDidMount() {
this.fetchSeedWordIndexes()
}

fetchSeedWordIndexes = () => {
const seedWordIndexes = []
while (seedWordIndexes.length < 3) {
const r = Math.floor(Math.random() * 24) + 1
if (seedWordIndexes.indexOf(r) === -1) {
seedWordIndexes.push(r)
}
}
this.setState({ seedWordIndexes })
}

setFormApi = formApi => {
this.formApi = formApi
}
Expand Down

0 comments on commit b9a54e2

Please sign in to comment.