Answers for "react native setstate object"

0

react setstate object

import React, { useState } from 'react'
const Example = () => {
  const [ account, setAccount ] = useState({ username: "", password: "" })
	return(
      <div>
      <p>Debug { JSON.stringify(account) }
		<form>
          <input 
			text="text" 
			placeholder="Username"
			onChange={(e) => {
              setAccount({ ...account, username: e.terget.value })
            }}
		  />
		  </br>
		  <input 
			text="text" 
			placeholder="Password"
			onChange={(e) => {
              setAccount({ ...account, password: e.terget.value })
            }}
		  />      
	  </form>
      </div>
    )
  }
  
 https://www.youtube.com/watch?v=nWGcOTyTkQ0&t=457s
Posted by: Guest on April-19-2021
0

react native setstate object

this.setState({
	lang1:{
		...this.state.lang1,
		name: "myExample"
	}
})
Posted by: Guest on September-08-2020
0

how use object in setstate

this.state = {
   jasper: { name: 'jasper', age: 28 },
}

this.setState({
    jasper: {
          ...this.state.jasper,
          name: 'something'
    }
})
Posted by: Guest on June-16-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language