Better handling of Container keys
This commit is contained in:
parent
6c029ac13c
commit
ca79e18e53
3 changed files with 4 additions and 4 deletions
|
@ -70,6 +70,7 @@ class App extends React.Component<IAppProps> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const container = new Container({
|
const container = new Container({
|
||||||
|
id: this.state.MainContainer.props.children.length.toString(),
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
width: 300,
|
width: 300,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
interface IContainerProps {
|
interface IContainerProps {
|
||||||
|
id: string,
|
||||||
// eslint-disable-next-line no-use-before-define
|
// eslint-disable-next-line no-use-before-define
|
||||||
children: Container[],
|
children: Container[],
|
||||||
x: number,
|
x: number,
|
||||||
|
@ -11,18 +12,15 @@ interface IContainerProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Container extends React.Component<IContainerProps> {
|
export class Container extends React.Component<IContainerProps> {
|
||||||
public static ContainerCount = 0;
|
|
||||||
|
|
||||||
componentWillUnMount() {
|
componentWillUnMount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): React.ReactNode {
|
public render(): React.ReactNode {
|
||||||
Container.ContainerCount++;
|
|
||||||
const containersElements = this.props.children.map(child => child.render());
|
const containersElements = this.props.children.map(child => child.render());
|
||||||
return (
|
return (
|
||||||
<g
|
<g
|
||||||
transform={`translate(${this.props.x}, ${this.props.y})`}
|
transform={`translate(${this.props.x}, ${this.props.y})`}
|
||||||
key={`container-${Container.ContainerCount}`}
|
key={`container-${this.props.id}`}
|
||||||
>
|
>
|
||||||
<rect
|
<rect
|
||||||
width={this.props.width}
|
width={this.props.width}
|
||||||
|
|
|
@ -16,6 +16,7 @@ export class MainContainer extends React.Component<IMainContainerProps> {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container
|
<Container
|
||||||
|
id={'main'}
|
||||||
x={0}
|
x={0}
|
||||||
y={0}
|
y={0}
|
||||||
width={this.props.width}
|
width={this.props.width}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue