Moved static GetDepth to getDepth class method
This commit is contained in:
parent
8792c8bee5
commit
be00496581
2 changed files with 13 additions and 13 deletions
|
@ -40,6 +40,18 @@ export class Container extends React.Component<IContainerProps> {
|
|||
}
|
||||
}
|
||||
|
||||
public getDepth() {
|
||||
let depth = 0;
|
||||
|
||||
let current: Container | null = this.props.parent;
|
||||
while (current != null) {
|
||||
depth++;
|
||||
current = current.props.parent;
|
||||
}
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
||||
public render(): React.ReactNode {
|
||||
const containersElements = this.props.children.map(child => child.render());
|
||||
const defaultStyle = {
|
||||
|
@ -69,16 +81,4 @@ export class Container extends React.Component<IContainerProps> {
|
|||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
public static getDepth(container: Container): number {
|
||||
let depth = 0;
|
||||
|
||||
let current: Container | null = container.props.parent;
|
||||
while (current != null) {
|
||||
depth++;
|
||||
current = current.props.parent;
|
||||
}
|
||||
|
||||
return depth;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue