Empty list causes react error
Opened this issue · 0 comments
ohjann commented
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.
is triggered when an empty array is passed to map function inside a List.
Can be recreated by changing ex2items
in Example.js to an empty array and running npm run dev
.
A workaround is to check the list length before mapping, but imo the expected behaviour is that it wouldn't error and that it would just render with an empty list, the same way you can render an empty <ul>
.