Skip to content

Instantly share code, notes, and snippets.

@benmvp
Created March 30, 2020 18:09
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 benmvp/f977114f5c3317a6e5d61f5e9e18189a to your computer and use it in GitHub Desktop.
Save benmvp/f977114f5c3317a6e5d61f5e9e18189a to your computer and use it in GitHub Desktop.
React FUNdamentals, Step 2 - Query Field Exercise
import React, { useState } from 'react'
const App = () => {
const [inputValue, setInputValue] = useState('')
const [isUpper, setIsUpper] = useState(false)
return (
<main>
<h1>Giphy Search!</h1>
<form>
<input
type="search"
placeholder="Search Giphy"
value={inputValue}
onChange={(e) => {
setInputValue(e.target.value)
}}
/>
</form>
<p style={{ textTransform: isUpper ? 'uppercase' : undefined }}>
You are typing <strong>{inputValue}</strong> in the field.
</p>
<button
type="button"
className="button"
onClick={() => setIsUpper((prevIsUpper) => !prevIsUpper)}
>
To upper ({isUpper ? 'off' : 'on'})
</button>
</main>
)
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment