Skip to content

Instantly share code, notes, and snippets.

@SebinLee
Created May 28, 2020 07:57
Show Gist options
  • Save SebinLee/13a26a1f73958106246d7e644b936603 to your computer and use it in GitHub Desktop.
Save SebinLee/13a26a1f73958106246d7e644b936603 to your computer and use it in GitHub Desktop.
React Testing Recipe 번역 - Events
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