Separated the model and the Container entity in order to remove any mutation operation
This commit is contained in:
parent
964d9a0e57
commit
e2a099457c
7 changed files with 206 additions and 178 deletions
|
@ -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 (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue