Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

90
Vistas
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.

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

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
      }
    ]);
  };
7 months 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 empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.