mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-12-25 15:21:19 +01:00
- removing nestedObjectUtils and useNotification hook - passing addNotification method to all components - components can use the addNotification method to create their notifications
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import React, { useEffect, useRef } from 'react';
|
|
import { DocStringComponent } from './DocStringComponent';
|
|
import { Attribute, GenericComponent } from './GenericComponent';
|
|
|
|
interface ListComponentProps {
|
|
name: string;
|
|
parentPath?: string;
|
|
value: Attribute[];
|
|
docString: string;
|
|
isInstantUpdate: boolean;
|
|
addNotification: (string) => void;
|
|
}
|
|
|
|
export const ListComponent = React.memo((props: ListComponentProps) => {
|
|
const { name, parentPath, value, docString, isInstantUpdate, addNotification } =
|
|
props;
|
|
|
|
const renderCount = useRef(0);
|
|
|
|
useEffect(() => {
|
|
renderCount.current++;
|
|
}, [props]);
|
|
|
|
return (
|
|
<div className={'listComponent'} id={parentPath.concat(name)}>
|
|
{process.env.NODE_ENV === 'development' && (
|
|
<p>Render count: {renderCount.current}</p>
|
|
)}
|
|
<DocStringComponent docString={docString} />
|
|
{value.map((item, index) => {
|
|
return (
|
|
<GenericComponent
|
|
key={`${name}[${index}]`}
|
|
attribute={item}
|
|
name={`${name}[${index}]`}
|
|
parentPath={parentPath}
|
|
isInstantUpdate={isInstantUpdate}
|
|
addNotification={addNotification}
|
|
/>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
});
|