Skip to content

Instantly share code, notes, and snippets.

@BarthesSimpson
Created June 24, 2019 04:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BarthesSimpson/58ab3a86552fdb973b2c266ff7f1e856 to your computer and use it in GitHub Desktop.
Save BarthesSimpson/58ab3a86552fdb973b2c266ff7f1e856 to your computer and use it in GitHub Desktop.
Memoized LetterInput
const MLetterInput = memo(
LetterInput,
({ value: _old }, { value: _new }) => _old === _new
)
//... Inside the render method of <Form/>
{Object.keys(alphabet).map((l, i) =>
state.itMatters ? (
<MLetterInput
key={l}
l={l}
i={i}
value={state[l]}
onChange={changeLetter(l)}
/>
) : (
<LetterInput
key={l}
l={l}
i={i}
value={state[l]}
onChange={changeLetter(l)}
/>
)
)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment