mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 08:20:02 +02:00
frontend: adding ListComponent
This commit is contained in:
parent
8c8e22cf70
commit
cc0397b23e
37
frontend/src/components/ListComponent.tsx
Normal file
37
frontend/src/components/ListComponent.tsx
Normal file
@ -0,0 +1,37 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { DocStringComponent } from './DocStringComponent';
|
||||
import { GenericComponent } from './GenericComponent';
|
||||
|
||||
interface ListComponentProps {
|
||||
name: string;
|
||||
parent_path?: string;
|
||||
value: object[];
|
||||
docString: string;
|
||||
}
|
||||
|
||||
export const ListComponent = React.memo((props: ListComponentProps) => {
|
||||
const renderCount = useRef(0);
|
||||
|
||||
useEffect(() => {
|
||||
renderCount.current++;
|
||||
});
|
||||
|
||||
const { name, parent_path, value, docString } = props;
|
||||
|
||||
return (
|
||||
<div className={'component boolean'} id={parent_path.concat(name)}>
|
||||
<p>Render count: {renderCount.current}</p>
|
||||
<DocStringComponent docString={docString} />
|
||||
{value.map((item, index) => {
|
||||
return (
|
||||
<GenericComponent
|
||||
key={`${name}[${index}]`}
|
||||
attribute={item}
|
||||
name={`${name}[${index}]`}
|
||||
parentPath={parent_path}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user