Skip to content

Instantly share code, notes, and snippets.

@codegagan
Last active September 6, 2020 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codegagan/cfb1a8934fee950dfd67043557fd61e1 to your computer and use it in GitHub Desktop.
Save codegagan/cfb1a8934fee950dfd67043557fd61e1 to your computer and use it in GitHub Desktop.
Test conditional rendering based on state
import React, { useState } from "react";
export default function ConditionalComponent() {
const [loading, setLoading] = useState(false);
return (
<div>
<h1>Conditional test</h1>
{loading ? <p>Loading....</p> : <p>Page loaded successfully</p>}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment