Skip to content

Instantly share code, notes, and snippets.

@muyiwaoyeniyi
Created March 11, 2026 15:53
Show Gist options
  • Select an option

  • Save muyiwaoyeniyi/c8c1cb2e7a977812375bc6ebca775f1b to your computer and use it in GitHub Desktop.

Select an option

Save muyiwaoyeniyi/c8c1cb2e7a977812375bc6ebca775f1b to your computer and use it in GitHub Desktop.
import React, { useState } from "react";
const User = ({ user }) => {
if (user.disabled) {
return <div>{`${user.name} is not active`}</div>;
} else {
const [showDetails, setShowDetails] = useState(true);
const toggleShowDetails = () => setShowDetails(!showDetails);
return (
<div>
<button type="button" onClick={toggleShowDetails}>
{showDetails ? "Collapse" : "Expand"}
</button>
{showDetails && (
<>
<span>{user.name}</span>
<span>{user.email}</span>
<span>{user.phoneNumber}</span>
</>
)}
</div>
);
}
};
export default User;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment