Created
June 6, 2019 17:34
-
-
Save ivanbtrujillo/1ed8bca0bd9ccc53e6e29c1b2dbeeb62 to your computer and use it in GitHub Desktop.
react-testing-library-article-7
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
import React, { useState } from "react"; | |
const Sum = () => { | |
const [value1, setValue1] = useState(); | |
const [value2, setValue2] = useState(); | |
const [result, setResult] = useState(); | |
const calculateSum = () => setResult(value1 + value2); | |
return ( | |
<div> | |
<input | |
data-testid="value1" | |
value={value1} | |
onChange={e => setValue1(e.target.value)} | |
/> | |
<input | |
data-testid="value2" | |
value={value2} | |
onChange={e => setValue2(e.target.value)} | |
/> | |
<button data-testid="sum-button" onClick={calculateSum} /> | |
<p data-testid="result-txt">{result}</p> | |
</div> | |
); | |
}; | |
export default Sum; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment