+ 1
Can we use a ternary operator under return in react hooks ??
Hii all !, Const [ status, setStatus ] = useState(true) //Under return status === true ? <div> Login <div/> : <div> Logout <div/> Output -- login Can anyone suggest a better way of doing this ? Thank you!
2 odpowiedzi
+ 2
Try this component App
function App () {
const [ status, setStatus ] = useState(true)
// under return
return (
<div>
{ status ? <div> Login </div> : <div> Logout </div> }
</div>
)
}
+ 1
Thank you Calviղ