Replaced usage of render() by their JSX constructor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Siklos 2022-08-05 16:23:33 +02:00
parent bc6d44db6a
commit b5aa002877
3 changed files with 13 additions and 12 deletions

View file

@ -14,7 +14,7 @@ export class Container extends React.Component<IContainerProps> {
* @returns Render the container * @returns Render the container
*/ */
public render(): React.ReactNode { public render(): React.ReactNode {
const containersElements = this.props.model.children.map(child => new Container({ model: child } as IContainerProps).render()); const containersElements = this.props.model.children.map(child => <Container key={`container-${child.properties.id}`} model={child} />);
const xText = Number(this.props.model.properties.width) / 2; const xText = Number(this.props.model.properties.width) / 2;
const yText = Number(this.props.model.properties.height) / 2; const yText = Number(this.props.model.properties.height) / 2;
const transform = `translate(${Number(this.props.model.properties.x)}, ${Number(this.props.model.properties.y)})`; const transform = `translate(${Number(this.props.model.properties.x)}, ${Number(this.props.model.properties.y)})`;

View file

@ -22,15 +22,16 @@ const getDimensionsNodes = (root: ContainerModel): React.ReactNode[] => {
const y = -(GAP * (getDepth(container) + 1)); const y = -(GAP * (getDepth(container) + 1));
const strokeWidth = 1; const strokeWidth = 1;
const text = width.toString(); const text = width.toString();
const dimension = new Dimension({ dimensions.push(
id, <Dimension
xStart, id={id}
xEnd, xStart={xStart}
y, xEnd={xEnd}
strokeWidth, y={y}
text strokeWidth={strokeWidth}
}); text={text}
dimensions.push(dimension.render()); />
);
} }
return dimensions; return dimensions;
}; };

View file

@ -43,9 +43,9 @@ export class SVG extends React.Component<ISVGProps> {
let children: React.ReactNode | React.ReactNode[] = []; let children: React.ReactNode | React.ReactNode[] = [];
if (Array.isArray(this.props.children)) { if (Array.isArray(this.props.children)) {
children = this.props.children.map(child => new Container({ model: child }).render()); children = this.props.children.map(child => <Container key={`container-${child.properties.id}`} model={child}/>);
} else if (this.props.children !== null) { } else if (this.props.children !== null) {
children = new Container({ model: this.props.children }).render(); children = <Container key={`container-${this.props.children.properties.id}`} model={this.props.children}/>;
} }
return ( return (