mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-12 15:57:12 +02:00
frontend: removing components.tsx
This commit is contained in:
@ -1,55 +0,0 @@
|
|||||||
import React, { useEffect, useRef } from 'react';
|
|
||||||
|
|
||||||
interface ComponentProps {
|
|
||||||
name: string;
|
|
||||||
parent_path: string;
|
|
||||||
value: any;
|
|
||||||
readOnly: boolean;
|
|
||||||
type: string;
|
|
||||||
docString: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ComponentLabel = ({
|
|
||||||
name,
|
|
||||||
docString
|
|
||||||
}: {
|
|
||||||
name: string;
|
|
||||||
docString: string;
|
|
||||||
}) => {
|
|
||||||
return <label title={docString}>{name}</label>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Component = React.memo(
|
|
||||||
({ name, parent_path, value, readOnly, type, docString }: ComponentProps) => {
|
|
||||||
const renderCount = useRef(0);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
renderCount.current++;
|
|
||||||
});
|
|
||||||
switch (type) {
|
|
||||||
case 'str':
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<p>Render count: {renderCount.current}</p>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name={name}
|
|
||||||
value={value}
|
|
||||||
readOnly={readOnly}
|
|
||||||
title={docString}
|
|
||||||
id={parent_path}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
case 'method':
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<p>Render count: {renderCount.current}</p>
|
|
||||||
<p>Method: {name}</p>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return <p>Unsupported type: {type}</p>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
Reference in New Issue
Block a user