Open angelogulina opened 7 years ago
@AngeloGulina nice :D
Going further:
const sampleComponent = () => {
const basicCondition = flag && flag2 && !flag3
const obj = {
'flag4': 'Blah',
'flag5: 'Meh'
}
return <p>{basicCondition ? obj[flagName] || Herp : Derp}</p>
}
However I prefer using cond
from lodash
in such a case ;)
@cytrowski, honestly I didn't think about cond
.
Good idea, thanks!
Given this: https://github.com/vasanthk/react-bits/blob/master/patterns/18.conditionals-in-jsx.md What about something like this: