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

67
Views
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
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!