Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

how to edit multiple inputs react

import React, { useState } from "react";

const initialContact = { firstName: "", lastName: "", phone: "" };

export default function App() {
  const [contact, setContact] = useState(initialContact);

  const handleChangeFor = (propertyName) => (event) => {
    setContact((contact) => ({
      ...contact,
      [propertyName]: event.target.value
    }));
  };

  return (
    <div>
      <input
        type="text"
        onChange={handleChangeFor("firstName")}
        value={contact.firstName}
      />
      <input
        type="text"
        onChange={handleChangeFor("lastName")}
        value={contact.lastName}
      />
      <input
        type="text"
        onChange={handleChangeFor("phone")}
        value={contact.phone}
      />
    </div>
  );
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: Statement.executeQuery() cannot issue statements that do not produce result sets. 
Typescript :: how to get docker stats using shell script 
Typescript :: multer s3 
Typescript :: How to specify output directory in TypeScript? 
Typescript :: echarts cdn 
Typescript :: js Validating nested objects 
Typescript :: absolute refrence of cell in excel 
Typescript :: how to define an array type in typescript 
Typescript :: An attempt was made to access a socket in a way forbidden by its access permissions. 
Typescript :: puts ruby example 
Typescript :: navigate in new tab with query params angular 
Typescript :: why in angular template i cant use Object.Keys() 
Typescript :: nodemailer typescript 
Typescript :: absolute path react native 
Typescript :: embed youtube search results into website 
Typescript :: ts Decorator pattern 
Typescript :: difference between never and void in typescript 
Typescript :: call function dynamically typescript 
Typescript :: spyon observable 
Typescript :: concat type typescript 
Typescript :: serenity.is center open dialog 
Typescript :: can ts object be strongly typed? 
Typescript :: mat datepicker timezone not correct 
Typescript :: typescript reduce filter examples 
Typescript :: +github graphql api get commits from repo 
Typescript :: update object in array in ngxrx store in angular 
Typescript :: python get elements from list of dictionaries 
Typescript :: use pipe in ts file angulr 
Typescript :: typescript class example 
Typescript :: laravel middleware for apis 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =