React + Typescript...Its return type 'Element | undefined' is not a valid JSX element.

React + Typescript...Its return type 'Element | undefined' is not a valid JSX element. I have a component where I did consume from an API that returns an array of objects but the parent component is giving me some error that says 'UsersTable' cannot be used as a JSX component. Its return type 'Element | undefined' is not a valid JSX element. Type 'undefined' is not assignable to type 'Element | null'. Please how do I get rid of this error?
13 Replies
Neto
Neto3y ago
you cant return a plain array in a component just jsx/tsx also the if(isSuccess) is probably the error because its reads if(isSuccess) return the data and looks like there is more on the file than the first print
Leke
LekeOP3y ago
I just removed the if(success) and the error is gone but i have another error
Neto
Neto3y ago
what error?
Leke
LekeOP3y ago
Neto
Neto3y ago
its correct if can do something with if(!data) ... to the tsserver be happy or data?.map usually the data?. is better too look at
Leke
LekeOP3y ago
its not working
Neto
Neto3y ago
after the if error if(!data) return null; and then the return with map
Leke
LekeOP3y ago
Leke
LekeOP3y ago
The error still persist
Neto
Neto3y ago
what is the error? on image it doesnt show
Leke
LekeOP3y ago
This is where the error is happening
Leke
LekeOP3y ago
The error says
Leke
LekeOP3y ago
I have resolved it Thank you
Want results from more Discord servers?
Add your server