Created
March 1, 2021 21:44
-
-
Save nafeu/edf536dc7e6e9a470bfde0140af0f24a to your computer and use it in GitHub Desktop.
This file contains 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
{ | |
Header: () => null, | |
id: 'expander', | |
Cell: ({ row, isLoading, isExpanded }) => { | |
const toggleRowExpandedProps = row.getToggleRowExpandedProps(); | |
const onClick = async event => { | |
if (!isLoading) { | |
if (!isExpanded) { | |
await onClickRow(row); | |
} | |
toggleRowExpandedProps.onClick(event); | |
} | |
} | |
if (isLoading) { | |
return <span>🔄</span> | |
} | |
return ( | |
<span | |
{...row.getToggleRowExpandedProps({ | |
style: { | |
paddingLeft: `${row.depth}rem`, | |
}, | |
})} | |
onClick={onClick} | |
> | |
{row.isExpanded ? '🔽' : '▶️'} | |
</span> | |
) | |
}, | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment