Condizioni per restituire un tag in JSX
È possibile restituire tramite return una variabile
che contiene un tag:
function App() {
let text;
const show = true;
if (show) {
text = <p>text1</p>;
} else {
text = <p>text2</p>;
}
return text;
}
Sia nella costante isAdmin contenuto
true, se l'utente è un amministratore, e false,
se non lo è:
function App() {
const isAdmin = true;
}
Fai in modo che, se isAdmin
ha valore true, sullo schermo appaia
un div con i paragrafi. In caso contrario non
è necessario mostrare nulla.