Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
Change nested object with one function in react

I have this kind of object where I want to change the Ethereum value for example;

const [reportData, setReportData] = useState({
  nameOrganization: "test5",
  socialMedia: "test",
  country: "aa",
  discord: "test",
  date: "date",
  time: "time",
  NFT: {
    ethereum: true,
    tezos: false,
    solana: false,
    other: "test",
  },
});

const changeData = (event: { target: { id: any, value: any } }) => {
  const { id, value } = event.target;
  setReportData({ ...reportData, [id]: value });
};

Can somebody help me to change the function in that way so I can change the Ethereum to.

This function works for country, date, or time.

Thanks a lot

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try spread NFT as well. (on side note, Actually React does not recommend have complex object as state variable, prefer reducer)

const changeData = (event: { target: { id: any, value: any } }) => {
  const { id, value } = event.target;
  setReportData({ ...reportData, NFT: { ...reportData.NFT, [id]: value } });
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!