idev0085 / react-boilerplate

0 stars 0 forks source link

How do you conditionally render components? #74

Open idev0085 opened 3 years ago

idev0085 commented 3 years ago

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. Use JavaScript operators like if or the conditional operator to create elements representing the current state, and let React update the UI to match them.