Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 39 additions & 38 deletions src/exercises-final/04.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,50 +163,51 @@ function Usage() {
}

return (
<PokemonCacheProvider>
<div style={{display: 'flex', flexDirection: 'column'}}>
<form
onSubmit={handleSubmit}
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<label htmlFor="pokemonName-input">Pokemon Name</label>
<small>
Try{' '}
<InvisibleButton onClick={() => handleSelect('pikachu')}>
"pikachu"
</InvisibleButton>
{', '}
<InvisibleButton onClick={() => handleSelect('charizard')}>
"charizard"
</InvisibleButton>
{', or '}
<InvisibleButton onClick={() => handleSelect('mew')}>
"mew"
</InvisibleButton>
</small>
<div>
<input
id="pokemonName-input"
name="pokemonName"
value={pokemonName}
onChange={handleChange}
/>
<button type="submit">Submit</button>
</div>
</form>
<hr />

<div style={{display: 'flex', flexDirection: 'column'}}>
<form
onSubmit={handleSubmit}
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<label htmlFor="pokemonName-input">Pokemon Name</label>
<small>
Try{' '}
<InvisibleButton onClick={() => handleSelect('pikachu')}>
"pikachu"
</InvisibleButton>
{', '}
<InvisibleButton onClick={() => handleSelect('charizard')}>
"charizard"
</InvisibleButton>
{', or '}
<InvisibleButton onClick={() => handleSelect('mew')}>
"mew"
</InvisibleButton>
</small>
<div>
<input
id="pokemonName-input"
name="pokemonName"
value={pokemonName}
onChange={handleChange}
/>
<button type="submit">Submit</button>
</div>
</form>
<hr />
<PokemonCacheProvider>
<div style={{display: 'flex'}}>
<PreviousPokemon onSelect={handleSelect} />
<div style={{marginLeft: 10}} data-testid="pokemon-display">
<PokemonInfo pokemonName={submittedPokemon} />
</div>
</div>
</div>
</PokemonCacheProvider>
</PokemonCacheProvider>
</div>
)
}
Usage.title = 'useContext: Caching response data in context'
Expand Down
77 changes: 39 additions & 38 deletions src/exercises/04.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,50 +178,51 @@ function Usage() {
}

return (
<PokemonCacheProvider>
<div style={{display: 'flex', flexDirection: 'column'}}>
<form
onSubmit={handleSubmit}
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<label htmlFor="pokemonName-input">Pokemon Name</label>
<small>
Try{' '}
<InvisibleButton onClick={() => handleSelect('pikachu')}>
"pikachu"
</InvisibleButton>
{', '}
<InvisibleButton onClick={() => handleSelect('charizard')}>
"charizard"
</InvisibleButton>
{', or '}
<InvisibleButton onClick={() => handleSelect('mew')}>
"mew"
</InvisibleButton>
</small>
<div>
<input
id="pokemonName-input"
name="pokemonName"
value={pokemonName}
onChange={handleChange}
/>
<button type="submit">Submit</button>
</div>
</form>
<hr />

<div style={{display: 'flex', flexDirection: 'column'}}>
<form
onSubmit={handleSubmit}
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<label htmlFor="pokemonName-input">Pokemon Name</label>
<small>
Try{' '}
<InvisibleButton onClick={() => handleSelect('pikachu')}>
"pikachu"
</InvisibleButton>
{', '}
<InvisibleButton onClick={() => handleSelect('charizard')}>
"charizard"
</InvisibleButton>
{', or '}
<InvisibleButton onClick={() => handleSelect('mew')}>
"mew"
</InvisibleButton>
</small>
<div>
<input
id="pokemonName-input"
name="pokemonName"
value={pokemonName}
onChange={handleChange}
/>
<button type="submit">Submit</button>
</div>
</form>
<hr />
<PokemonCacheProvider>
<div style={{display: 'flex'}}>
<PreviousPokemon onSelect={handleSelect} />
<div style={{marginLeft: 10}} data-testid="pokemon-display">
<PokemonInfo pokemonName={submittedPokemon} />
</div>
</div>
</div>
</PokemonCacheProvider>
</PokemonCacheProvider>
</div>
)
}
Usage.title = 'useContext: Caching response data in context'
Expand Down