Created
May 28, 2020 07:57
-
-
Save SebinLee/13a26a1f73958106246d7e644b936603 to your computer and use it in GitHub Desktop.
React Testing Recipe 번역 - Events
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
import React, { useState } from "react"; | |
export default function Toggle(props) { | |
const [state, setState] = useState(false); | |
return ( | |
<button | |
onClick={() => { | |
setState(previousState => !previousState); | |
props.onChange(!state); | |
}} | |
data-testid="toggle" | |
> | |
{state === true ? "Turn off" : "Turn on"} | |
</button> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment