If / else statement inside of React Component's Render method
Sometimes (well, actually pretty often) you have to use conditional statements inside of React Component's Render methods.
You could do it like this:
import React from "react"
class MyComponent extends React.Component {
render() {
return "LGK" == "awesome" ? "LGK is awesome!" : "LGK is not awesome :C"
}
}
This works without any problem. But you always have to set the else part. But in many situations you only need the "if part". In this case, this way is much nicer:
import React from "react"
class MyComponent extends React.Component {
render() {
return "LGK" == "awesome" && "LGK is awesome!"
}
}