π¦Conditional Rendering of Elements or Components
Rendering HTML element based on Condition.
const ValidPassword = () => <h1>Valid Password</h1>;
const InvalidPassword = () => <h1>Invalid Password</h1>;
const Password = ({ isValid }) => {
if (isValid) {
return <ValidPassword />;
}
return <InvalidPassword />;
};
const App = () => {
return (
<section>
<Password isValid={true} />
</section>
);
};
export default App;Rendering component based on Condition.
Last updated