Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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'))
Comment

PREVIOUS NEXT
Code Example
Javascript :: Error: Error: Could not resolve [object Object] / undefined at Scope.resolve 
Javascript :: how to add elements in javascript html 
Javascript :: onresize js 
Javascript :: javascript autoplay audio 
Javascript :: change elements class javascript 
Javascript :: debounce in react native hooks 
Javascript :: view all local storage js 
Javascript :: javascript json upload 
Javascript :: node.js socket.io send data with handshake 
Javascript :: javascript log error without traceback 
Javascript :: unable to resolve path to module eslint(import/no-unresolved) absoute path 
Javascript :: vscode file cannot be loaded because running scripts is disabled on this system 
Javascript :: install aos in react 
Javascript :: jquery on click dynamic element 
Javascript :: jquery text replace 
Javascript :: stateprovider.js react 
Javascript :: vscode jsx html autocomplete 
Javascript :: file name without extension javascript 
Javascript :: angular command to create interceptor 
Javascript :: javascript regex vowel 
Javascript :: how to get the min value of two variables in math 
Javascript :: how to remove duplicates from array in javascript 
Javascript :: python http request post json example 
Javascript :: jquery trigger click other element 
Javascript :: useHistory goback 
Javascript :: jest global window object 
Javascript :: js get domain 
Javascript :: refresh page after delete angular 
Javascript :: unexpected token export type react bottontab navigation 
Javascript :: jquery find child of parent sibling 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =