Skip to content

Type 'boolean' is not assignable to type 'CollectionElement<object>'.ts(2322) #2137

Answered by ayanonline
ayanonline asked this question in Help
Discussion options

You must be logged in to vote
{!loading && isLoggedIn && (
     <DropdownItem key="logout">Logout</DropdownItem>
)}

how can I solve this error

ERROR: Type 'false | Element' is not assignable to type 'CollectionElement'.Type 'boolean' is not assignable to type 'CollectionElement'.ts(2322)

Please let me know if you found a solution for this. I am looking for the same.

simply add hidden prop with you condition
<DropdownItem
hidden={!isLoggedIn }
key="logout"
textValue="Logout"
onClick={logoutHandler}
>
Logout

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@ayanonline
Comment options

Answer selected by ayanonline
@Harshal3110
Comment options

Comment options

You must be logged in to vote
1 reply
@Harshal3110
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants