Replace `child.type.name`, as it is not available in the production build

This commit is contained in:
Deluan 2020-05-22 22:23:00 -04:00
parent 0a3e6c66c1
commit 3632608de0
1 changed files with 12 additions and 9 deletions

View File

@ -12,6 +12,7 @@ export const SongDatagridRow = ({
}) => {
const translate = useTranslate()
const [visible, setVisible] = useState(false)
const childCount = React.Children.count(children)
return (
<>
{multiDisc && (
@ -38,15 +39,17 @@ export const SongDatagridRow = ({
onMouseLeave={() => setVisible(false)}
{...rest}
>
{React.Children.map(children, (child) =>
child &&
isValidElement(child) &&
child.type.name === 'SongContextMenu'
? cloneElement(child, {
visible: contextVisible || visible,
...rest,
})
: child
{React.Children.map(
children,
(child, index) =>
child &&
isValidElement(child) &&
(index < childCount - 1
? child
: cloneElement(child, {
visible: contextVisible || visible,
...rest,
}))
)}
</DatagridRow>
</>