React is component based so we can have different components and add some conditions to render them only when the condition is satisfied.
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.
Let’s add couple of components:
How to store elements in variables?
We can store elements in variables and then render just some part of the component.
We can create a stateful component that will render depending on its current or previous state.
Source: React Docs