convert component to function
@@ -13,19 +13,18 @@ interface Props {
adjacencyList: { [key: string]: Edge[] };
}
-class Connections extends React.Component<Props, any> {
- render() {
+export const Connections: React.StatelessComponent<Props> = ({offsets, adjacencyList}) => {
const connections: JSX.Element[] = []
- for (const key in this.props.adjacencyList) {
- if (this.props.offsets[key]) {
- const parentRect = this.props.offsets[key]
+ for (const key in adjacencyList) {
+ if (offsets[key]) {
+ const parentRect = offsets[key]
if (parentRect) {
- const list = this.props.adjacencyList[key]
+ const list = adjacencyList[key]
connections.push(
...list.map((edge: Edge, id: number) => {
- const childRect = this.props.offsets[edge.node]
+ const childRect = offsets[edge.node]
let start = { x: parentRect.left, y: parentRect.top }
let end = { x: childRect.left, y: childRect.top }
const edgeID = `${key}-${id}`
@@ -100,6 +99,3 @@ class Connections extends React.Component<Props, any> {
</svg>
)
}
-}
-
-export default Connections
