Add element-separator (#42)

Add element-separator

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
mrdrogdrog 2020-05-17 23:21:10 +02:00 committed by GitHub
parent 0e18d0f8da
commit 90d9ba5226
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,22 @@
import React, {Fragment} from "react";
export interface ElementSeparatorProps {
separator: React.ReactElement
}
export const ElementSeparator: React.FC<ElementSeparatorProps> = ({children, separator}) => {
return (
<Fragment>
{
React.Children.map(children, (child, index) => {
return <Fragment>
{
(index > 0) ? separator : null
}
{child}
</Fragment>
})
}
</Fragment>
)
}