Objects are not valid as a React child why does the error occur?

  • 0
    I have an array, with a lot of objects like this:
          logo: "logo",
          marketName: "Company and Software",
          region: true,
          lineBusiness: 50,
          industry: 5,
          growth: 4,
          commission: 3,
          id: 0,
          star: false,
          isSelected: true,

    And I need to sort this array, for example in ascending order of growth numbers, but when I use I do the sorting like this:

    filteredData.sort ((a, b) = & gt; a.growth - b.growth);

    I am throwing this error:
    Uncaught Error: Objects are not valid as a React child (found: object with keys {logo, marketName, region, lineBusiness, industry, growth, commission, id, star, isSelected}). If you meant to render a collection of children, use an array instead.
    JavaScript Emily Fields, Mar 29, 2020

  • 1 Answers
  • 0
    The problem is not with this code, but with the rendering. You are trying to render an object (or an array, which is the same), and react cannot render objects. What is reported in the error text
    Logan Barber

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!