Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

usestate with string

// usestate with string

const [name, setName] = useState('')
const onChange = (e) => {
  setName(e.target.value)
}

return (
  <>
    <form>
      <input type="text" onChange={onChange} value={name} />
  // or   <input type="text" onChange={(e) => setName(e.target.value)} value={name} />
    </form>
    <h2>{name}</h2>
  </>
);
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript round down 
Javascript :: AWS S3 JavaScript example 
Javascript :: regex numéro de téléphone 
Javascript :: javascript parse xml 
Javascript :: vuejs react on route chagne 
Javascript :: react dictionary key value avec 2 variable 
Javascript :: write html in javascript 
Javascript :: order array of objects by id javascript 
Javascript :: list all files in s3 bucket 
Javascript :: Vuejs watch for nested data 
Javascript :: datatables integration 
Javascript :: npx create-react-app current folder 
Javascript :: remove jquery 
Javascript :: how to check if a number is a whole number in javascript 
Javascript :: ajax failure response 
Javascript :: javascript caesar cipher 
Javascript :: get input type js 
Javascript :: how to pass state values as initial data and support state updates for Formik while using useFormik hook 
Javascript :: sh: 1: react-scripts: not found 
Javascript :: how to auto refresh a div js 
Javascript :: import fetch from ("node-fetch"); ^^^^^^ SyntaxError: Cannot use import statement outside a module 
Javascript :: jquery sort listing alphabetically 
Javascript :: gulp run sequence 
Javascript :: all javascript pattern programs 
Javascript :: get children jquery index 
Javascript :: jquery unfocus 
Javascript :: node js to int 
Javascript :: how to get enum item name in javascript 
Javascript :: npm run shell script 
Javascript :: javascript is int in array 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =