frontend: removing components.tsx

This commit is contained in:
Mose Müller
2023-08-02 12:06:20 +02:00
parent 00c2cf7110
commit 50162cdc82

View File

@ -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>;
}
}
);