Created
May 3, 2020 23:34
-
-
Save marshallmurphy/91a2ba74bd27915f93b42f6031fc0aba 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
... | |
const ToggleRow = ({ option }) => { | |
const [active, setActive] = useState(false); | |
// onKeyDown function for handling enter (13) press | |
function handleToggle(e) { | |
e.keyCode === 13 && setActive(!active); | |
} | |
return ( | |
<div className={styles.toggleRow}> | |
{option} | |
<label className={styles.toggle} tabIndex='0' onKeyDown={e => handleToggle(e)}> // add onKeyDown function | |
<input | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment