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
return ( | |
<div> | |
<AppContent | |
onChange={(cb) => { | |
setCollapsed(false) | |
onChange(cb) | |
}} | |
/> | |
</div> | |
) |
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
function handleOnChange(e) { | |
if (onChange) { | |
onChange(function({ person, collapsed }) { | |
console.log(`collapsed: ${collapsed}`) | |
console.log(`person: ${JSON.stringify(person)}`) | |
setValue(e.target.value) | |
}) | |
} | |
} |
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
function AppContent({ onChange }) { | |
const [value, setValue] = React.useState('') | |
function handleOnChange(e) { | |
if (onChange) { | |
onChange(function({ person, collapsed }) { | |
console.log(collapsed) | |
console.log(person) | |
setValue(e.target.value) | |
}) |
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
function ListComponent({ | |
label, | |
items = [], | |
collapsed, | |
toggle, | |
limit, | |
total, | |
renderListItem, | |
renderCollapser, | |
renderExpander, |
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
function ListComponent({ | |
label, | |
items = [], | |
collapsed, | |
toggle, | |
limit, | |
total, | |
renderListItem, | |
}) { | |
return ( |
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
function List({ | |
component: RootComponent = ListRoot, | |
collapsed, | |
toggle, | |
header, | |
label, | |
items = [], | |
limit = 3, | |
renderHeader, | |
renderList, |
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
function ListComponent({ label, items = [], collapsed, toggle, limit, total }) { | |
return ( | |
<ul> | |
<p>{label}</p> | |
{items.map((member) => ( | |
<ListItem key={member}>{member}</ListItem> | |
))} | |
{total > limit && ( | |
<ListItem className="expand"> | |
<button type="button" onClick={toggle}> |
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
function App() { | |
const [collapsed, setCollapsed] = React.useState(true) | |
function toggle() { | |
setCollapsed((prevValue) => !prevValue) | |
} | |
const pediatricians = [ | |
'Michael Lopez', | |
'Sally Tran', |
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
function List({ | |
component: RootComponent = ListRoot, | |
collapsed, | |
toggle, | |
header, | |
label, | |
items = [], | |
limit = 3, | |
renderHeader, | |
renderList, |
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
function List({ | |
collapsed, | |
toggle, | |
header, | |
label, | |
items = [], | |
limit = 3, | |
renderHeader, | |
renderList, | |
}) { |