Created
June 24, 2019 04:12
-
-
Save BarthesSimpson/58ab3a86552fdb973b2c266ff7f1e856 to your computer and use it in GitHub Desktop.
Memoized LetterInput
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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