Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Is single-line conditional rendering possible?

$
0
0

How to render conditional elements in Blazor like in React JSX?

For example in React:

export const LoginPage: FC = () => {  // useState's  // useEffect's  return <div>{!loadingState ? usernameState : <Spin />}</div>; // <-- Goal};

And I've tried in Blazor:

<div>  You logged in AS:  @if (_loading)  {<Spin/>  }  else  {    @_userName  }</div>

is there any way how to write this in one line?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>