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

66
Visualizações
How to add more details children inside useRef

I have the following data where useRef contains following information.

Data

{
    token: '', 
    id: '',
    versionId: '',
    additionalId: ''
}

The above is coming from the children within the useRef() as follows.

const formRef = useRef();
// other logic

// above Data
const aboveData = formRef.current.children;

Is there a way I can append to children to hold overallInfo block as follows?

{
    token: '', 

    // these 3 no longer needed but can remain if no way to delete
    id: '',
    versionId: '',
    additionalId: '',

    // I want to add this additional block
    overallInfo: {
      id: '',
      versionId: '',
      additionalId: ''
    }
}

UPDATE:

This is the form

const Form = ({
  formRef,
}) => (
  <form id="form" ref={formRef} method="POST">
    <input name="token" type="hidden" />
    <input name="id" type="hidden" />
    <input name="versionId" type="hidden" />
    <input name="additionalId" type="hidden" />
  </form>
);

export default Form;

OverallInfo is not coming from anywhere. I am purposely wrapping those 3 keys again cos client needs it to come in that format when I post.

This is how I am posting it. currently which is wrong cos I am not wrapping it inside OverallInfo.

export const PostForm = (
  formRef,
  link,
) => {

  // formRef.current.children definitely has all the token, 
  // id, versionId and additionalId values at this stage

  formRef.current.action = link;
  formRef.current.submit();
};

SOLUTION SUGGESTION BELOW:

export const PostForm = (
    formRef,
    link,
) => {
  const updatedRequest = {
      overallInfo: {},
  };

  [...formRef.current.children].forEach((child) => {
    updatedRequest.overallInfo[child.name] = child.value;
  });

  const newRef = useRef(updatedRequest);

  newRef.current.action = link;
  newRef.current.submit();
};
about 4 years ago · Juan Pablo Isaza
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