Conditional rendering
You can't use if/else statements inside a component, but conditional (ternary) operator and short-circuit evaluation works!
Instead of if do
{
condition && <Text>Rendered when `true`</Text>;
}
Instead of if/else do
{
condition ? (
<Text>Rendered when `true`</Text>
) : (
<Text>Rendered when `false`</Text>
);
}
Subscribe?
Be the first to receive insightful articles and actionable resources that help you to elevate your skills.