Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda