I am trying to render a line using react-native-svg
renderBox = (strategy) => {
const { x, y, fill, lineStartX, lineStartY, lineEndX, lineEndY} = this.getBoxDetails(strategy);
return (
<G>
<Line
x1={lineStartX}
y1={lineStartY}
x2={lineEndX}
y2={lineEndY}
stroke="red"
strokeWidth="2"
/>
</G>
);
};
I like to set the data for the line by using an array of objects in my switch
:
switch (strategy) {
case 'Situations':
return {
x: this.diagramWidth / 2 - this.boxWidth / 2,
y: 5,
fill: color,
lines: [{
lineStartX: this.diagramWidth / 2,
lineStartY: this.boxHeight,
lineEndX: this.diagramWidth - (this.diagramWidth / 4),
lineEndY: this.boxHeight * 2
}]
};
How can I loop through the 'lines' array and generate a line
for each object?