Created
February 4, 2021 19:20
-
-
Save rzymek/6bff654a58d9fa04ceed223c7cd7f72a to your computer and use it in GitHub Desktop.
This file contains 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
function Calculator() { | |
const [input, setInput] = useState(''); | |
const [result, setResult] = useState<number>() | |
return <div> | |
<input data-testid='expression' onChange={e => setInput(e.target.value)}/> | |
<button data-testid='calculate' onClick={() => setResult(eval(input))}/> | |
<div data-testid='result'>{result}</div> | |
</div> | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment