Snippets Collections
function App() {
  const [checked, setChecked] = useState(false);
  const toggleChecked = () => setChecked(value => !value);
  return (
    <input
      type="checkbox"
      checked={checked}
      onChange={toggleChecked}
    />
  );
}
star

Wed Jun 09 2021 14:45:35 GMT+0000 (UTC) https://stackoverflow.com/questions/40359800/how-to-toggle-boolean-state-of-react-component

#react.js #javascript #checkboxtoggle

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension