Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

104
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda