Created
October 2, 2020 18:19
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
class Index extends React.Component { | |
render() { | |
let mySpan; | |
if(true) { | |
mySpan = <span>Her er noe tekst</span> | |
} else { | |
mySpan = <span>Something is wrong</span> | |
} | |
return ( | |
<div> | |
{mySpan} | |
</div> | |
); | |
} | |
} |
Evt. på 1 linje:
const Index = ({condition}) => <div><span>{condition ? 'Her er noe tekst' : 'Something is wrong'}</span></div>
Takk for kommentarene. Vet at metoden som dere hendviser til er standarden, ville bare vise hvor mye boilerplate det er mulig å lage hvis man ikke er forsiktig :).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Evt på 5 linjer: