Created
March 11, 2026 15:53
-
-
Save muyiwaoyeniyi/c8c1cb2e7a977812375bc6ebca775f1b 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