I am converting from C# views to using react. I want to render some html depending on whether the user is authenticated or not, in C# this was as easy as this:
<ul class="outer pull-right">
@if (User.Identity.IsAuthenticated)
{
<li>
<form action="logout" id="logout-form">
<input type="submit" value="Logout" />
</form>
</li>
}
</ul>
What is the correct way to do this in react.js? Pseudocode For example:
export default class Nav extends React.Component {
getCurrentUser(){
//Use ajax to get current user from server?
}
render(){
return (
<ul class="outer pull-right">
@if (User.Identity.IsAuthenticated)
{
<li>
<form action="logout" id="logout-form">
<input type="submit" value="Logout" />
</form>
</li>
}
</ul>
);
}
}