Last active
February 27, 2026 19:20
-
-
Save muyiwaoyeniyi/ad32f055e85659ffa689781b3e10ab8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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