Separated the model and the Container entity in order to remove any mutation operation
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Siklos 2022-08-04 12:57:34 +02:00
parent 964d9a0e57
commit e2a099457c
7 changed files with 206 additions and 178 deletions

View file

@ -1,11 +1,12 @@
import * as React from 'react';
import { ReactSVGPanZoom, Tool, Value, TOOL_PAN } from 'react-svg-pan-zoom';
import { Container } from './Elements/Container';
import { ContainerModel } from './Elements/ContainerModel';
import { Selector } from './Elements/Selector';
interface ISVGProps {
children: Container | Container[] | null,
selected: Container | null
children: ContainerModel | ContainerModel[] | null,
selected: ContainerModel | null
}
interface ISVGState {
@ -65,9 +66,9 @@ export class SVG extends React.Component<ISVGProps> {
let children: React.ReactNode | React.ReactNode[] = [];
if (Array.isArray(this.props.children)) {
children = this.props.children.map(child => child.render());
children = this.props.children.map(child => new Container({ model: child }).render());
} else if (this.props.children !== null) {
children = this.props.children.render();
children = new Container({ model: this.props.children }).render();
}
return (