Skip to content

Instantly share code, notes, and snippets.

@data-miner00
Created February 3, 2023 00:27
Show Gist options
  • Save data-miner00/c94ce306ecd2234183874fd80503011d to your computer and use it in GitHub Desktop.
Save data-miner00/c94ce306ecd2234183874fd80503011d to your computer and use it in GitHub Desktop.
Collapsible View
import React, { useState } from "react"
function App() {
const [expanded, setExpanded] = useState(false)
return (
<div onClick={() => setExpanded(prev => !prev)}>
<h1>This is a title</h1>
{expanded && (
<div className="collapsible-content">
<p>This is a collapsible paragraph</p>
</div>
)}
</div>
)
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment