React Conditionals

Conditional rendering in React.

React Conditional Rendering

In React, you can create distinct components that encapsulate behavior you need.

Then, you can render only some of them, depending on the state of your application.

Conditional rendering in React works the same way conditions work in JavaScript.

Example

function Goal(props) {
  const isGoal = props.isGoal;
  if (isGoal) {
    return <MadeGoal />;
  }
  return <MissedGoal />;
}