score:3

Accepted answer
const toggleButton = () => {
  const { isOpen } = state;
  setState({ isOpen: !isOpen });
};

score:0

setState(prevState => ({
  isOpen: !prevState.isOpen
}));

score:0

export default function App() {
  const [isOpen, useIsOpen] = useState(false);
  const toggleButton = () => useIsOpen(!isOpen);

  return (
  <div className="App">
  <button onClick={toggleButton}>Show</button>
  </div>
  );
}

Related Query

More Query from same tag