1

i am having an error with below code. it shows module build failed. I think the structure is missing some tag

<tbody>
          {
            ListItems.map((section) =>
              <tr key={section.id}>
                <td>{section.name}</td>
              </tr>
                  {
                section.items.map((item) =>
                
                  <tr key={item.id}> // the error is here
                    <td>{item.productName}</td>
                  </tr>
                )})}
        </tbody>

1 Answers1

1

You need to use proper paranthesis and wrap everything inside fragment as follows.

<tbody>
  {
    ListItems.map((section) => (
      <Fragment key={section.id}>
        <tr key={section.id}>
          <td>{section.name}</td>
        </tr>
          {
             section.items.map((item) => (
               <tr key={item.id}>
                   <td>{item.productName}</td>
               </tr>
             )
           }
      </Fragment>
      )
    }
</tbody>
Explorer
  • 45
  • 12