Comment

Comment by funkiee

More on that point. The reason you cannot use if/else within JSX is because the statement needs to evaluate to an expression. If you really need to use if/else logic embedded, a ternary operator would work just fine.

return ( <nav> <Home /> { loggedIn ? <LogoutButton /> : <LoginButton /> } </nav> );

parent funkiee 11 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton