mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-07 14:00:40 +02:00
adds first version of DictComponent
This commit is contained in:
parent
6cae76bde1
commit
d40d9c5e47
42
frontend/src/components/DictComponent.tsx
Normal file
42
frontend/src/components/DictComponent.tsx
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import React, { useEffect, useRef } from 'react';
|
||||||
|
import { DocStringComponent } from './DocStringComponent';
|
||||||
|
import { SerializedValue, GenericComponent } from './GenericComponent';
|
||||||
|
import { LevelName } from './NotificationsComponent';
|
||||||
|
|
||||||
|
type DictComponentProps = {
|
||||||
|
value: Record<string, SerializedValue>;
|
||||||
|
docString: string;
|
||||||
|
isInstantUpdate: boolean;
|
||||||
|
addNotification: (message: string, levelname?: LevelName) => void;
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DictComponent = React.memo((props: DictComponentProps) => {
|
||||||
|
const { value, docString, isInstantUpdate, addNotification, id } = props;
|
||||||
|
|
||||||
|
const renderCount = useRef(0);
|
||||||
|
const valueArray = Object.values(value);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
renderCount.current++;
|
||||||
|
}, [props]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={'listComponent'} id={id}>
|
||||||
|
{process.env.NODE_ENV === 'development' && (
|
||||||
|
<div>Render count: {renderCount.current}</div>
|
||||||
|
)}
|
||||||
|
<DocStringComponent docString={docString} />
|
||||||
|
{valueArray.map((item) => {
|
||||||
|
return (
|
||||||
|
<GenericComponent
|
||||||
|
key={item.full_access_path}
|
||||||
|
attribute={item}
|
||||||
|
isInstantUpdate={isInstantUpdate}
|
||||||
|
addNotification={addNotification}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user