question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Element type is invalid

See original GitHub issue

Dear all,

Representation of your work is great! I’m trying to use your library, but without success, thats why I need a help from you… I gett an error: “Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.”. I have applied all the suggested steps of installation and appling from your part. Below is a part of my component’s code: <Table {...getTableProps()} > <Thead> { headerGroups.map(headerGroup => ( <Tr {...headerGroup.getHeaderGroupProps()}> { // Gives us access to each column headerGroup.headers.map( column => ( <Th {...column.getHeaderProps(column.getSortByToggleProps())}> {column.render('Header')} <span> {column.isSorted ? (column.isSortedDesc ? ' ▼' : ' ▲') : ''} </span> </Th> )) } </Tr> )) } </Thead> <Tbody {...getTableBodyProps()}> { page.map(row => { prepareRow(row) return( <Tr {...row.getRowProps()}> { row.cells.map( cell=> { return <Td {...cell.getCellProps()}>{cell.render('Cell')}</Td> }) } </Tr> ) }) } </Tbody> </Table>

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
guissmejiacommented, Apr 9, 2022

I had the same error a few days ago, I also wanted to use both libraries, react-table for its ease of creating tables and react-super-responsive-table for the ease it gives for the responsive of the table.

I solved it by leaving the TR out of the .map that is made to headerGroups, being as follows:

Before:

<table {...getTableProps()}> <thead> {headerGroups.map((headerGroup) => ( <tr {...headerGroup.getHeaderGroupProps()}> {headerGroup.headers.map((column) => ( <th {...column.getHeaderProps()}>{column.render("Header")}</th> ))} </tr> ))} </thead> <tbody {...getTableBodyProps()}> {rows.map((row) => { prepareRow(row); return ( <tr {...row.getRowProps()}> {row.cells.map((cell) => { return ( <td {...cell.getCellProps()}>{cell.render("Cell")}</td> ); })} </tr> ); })} </tbody> </table>

After:

<Table {...getTableProps()}> <Thead> <Tr> {headerGroups.map((headerGroup) => headerGroup.headers.map((column) => ( <Th {...column.getHeaderProps()}>{column.render("Header")}</Th> )) )} </Tr> </Thead> <Tbody {...getTableBodyProps()}> {rows.map((row) => { prepareRow(row); return ( <Tr {...row.getRowProps()}> {row.cells.map((cell) => { return ( <Td {...cell.getCellProps()}>{cell.render("Cell")}</Td> ); })} </Tr> ); })} </Tbody> </Table>

I hope it can work for you.

0reactions
stale[bot]commented, Nov 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: Element type is invalid: expected a string ...
This error can rise if you try to import a non-existent component. Make sure you have no typo and that the component indeed...
Read more >
Element type is invalid: expected a string (for ... - OneCompiler
Element type is invalid : expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Read more >
Element type is invalid: expected a string (for built-in ... - Reddit
Getting Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: ...
Read more >
Element type is invalid: expected a string (for built-in ... - GitHub
The app breaks and gives this error message: Element type is invalid: expected a string (for built-in components) or a class/function (for ...
Read more >
(React) Element type is invalid, expected a string (for built in ...
To solve the error "Element type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got", ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found