Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

use setstate in function component

const App = () => {
  const [state, setState] = React.useState({ first: "hello", second: "world" });
  
  return (
    <div>
      <input type="text" value={state.first} onChange={(ev) => setState({...state, first: ev.target.value})} />
      <input type="text" value={state.second} onChange={(ev) => setState({...state, second: ev.target.value})} />
    </div>
  )


}


ReactDOM.render(<App />, document.getElementById('app'))
Comment

PREVIOUS NEXT
Code Example
Javascript :: for of loop in es6 
Javascript :: react webpack config example 
Javascript :: use get_json in jstree example 
Javascript :: generate a random number between min and max 
Javascript :: namespace in javascript 
Javascript :: active navbar in page reactjs 
Javascript :: ISS proxy express 
Javascript :: Send Post Fetch REquest With Django 
Javascript :: webpack error cannot find module 
Javascript :: axios patch 
Javascript :: modulo operator in javascript 
Javascript :: recursion in javascript 
Javascript :: javascript DOM query selector 
Javascript :: jquery datatime 
Javascript :: get position of element in react 
Javascript :: js dictionary to extract the same key bvalues 
Javascript :: new Date() get speicifc hours min sec 
Javascript :: javascript string replace all 
Javascript :: strpos in javascript 
Javascript :: mongoBD $inc operator 
Javascript :: materialize open modal on load 
Javascript :: discord.js setactivity 
Javascript :: cookie options 
Javascript :: custom timestamp name mongoose 
Javascript :: check which is dubicate in object of array 
Javascript :: how to convert string to camel case in javascript 
Javascript :: javascript delay action 
Javascript :: check object is empty javascript 
Javascript :: radio javascript checked 
Javascript :: how to enable javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =