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
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 printI just removed the if(success) and the error is gone
but i have another error
what error?
its correct
if can do something with
if(!data) ...
to the tsserver be happy
or
data?.map
usually the data?.
is better too look atits not working
after the if error
if(!data) return null;
and then the return with mapThe error still persist
what is the error?
on image it doesnt show
This is where the error is happening
The error says
I have resolved it
Thank you