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

368
Views
react: ReactGridLayout.children[0].x must be a number

The issue is not similar to the one with the same title.

I am using react hook to create my own dynamic add/remove using this example to create my dynamic add/remove.

As the title suggests, the error message happens when clicking the 'create item' button.

This is my codesandbox link that shows my code and the error. Any help is appreciated.

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

0

The issue you were having is that your widget state is set as an array of objects but when you were updating that state in the onAddItem function you were setting the it as an object.

Here's the onAddItem function where the widget state is being updated with the previous state and the new state into a new array.

const onAddItem = () => {
    setCounter(counter + 1);
    setWidgetList([
      ...widget,
      {
        i: "chart" + counter,
        x: (widget.length * 2) % (cols || 12),
        y: Infinity, // puts it at the bottom
        w: 2,
        h: 2
      }
    ]);
  };
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!