Skip to content

Instantly share code, notes, and snippets.

@muyiwaoyeniyi
Last active February 27, 2026 19:20
Show Gist options
  • Select an option

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

Select an option

Save muyiwaoyeniyi/ad32f055e85659ffa689781b3e10ab8b 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