Answers for "usestate hook for checkbox check and uncheck"

0

usestate hook for checkbox check and uncheck

const { useState } = React; // --> for inline use
// import React, { useState } from 'react';  // --> for real project


const App = () => {
  const [checked, setChecked] = useState(false)
  const handleClick = () => setChecked(!checked)
  
  return <input onClick={handleClick} checked={checked} type="checkbox" />
};


ReactDOM.render(<App />, document.getElementById('root'))
Posted by: Guest on November-03-2020

Code answers related to "usestate hook for checkbox check and uncheck"

Code answers related to "Javascript"

Browse Popular Code Answers by Language