Render count: {renderCount.current}
diff --git a/frontend/src/components/MethodComponent.tsx b/frontend/src/components/MethodComponent.tsx
new file mode 100644
index 0000000..18be070
--- /dev/null
+++ b/frontend/src/components/MethodComponent.tsx
@@ -0,0 +1,97 @@
+import React, { useState, useEffect, useRef } from 'react';
+import { socket } from '../socket';
+import { Button, InputGroup, Form, Collapse } from 'react-bootstrap';
+import { DocStringComponent } from './DocStringComponent';
+
+interface MethodProps {
+ name: string;
+ parent_path: string;
+ parameters: { [key: string]: string };
+ docString?: string;
+ hideOutput?: boolean;
+}
+
+export const MethodComponent = React.memo((props: MethodProps) => {
+ const renderCount = useRef(0);
+ const [hideOutput, setHideOutput] = useState(false);
+
+ // Add a new state variable to hold the list of function calls
+ const [functionCalls, setFunctionCalls] = useState([]);
+
+ const { name, parent_path, docString } = props;
+
+ const execute = async (event: React.FormEvent) => {
+ event.preventDefault();
+
+ const args = {};
+ Object.keys(props.parameters).forEach(
+ (name) => (args[name] = event.target[name].value)
+ );
+ socket.emit(
+ 'frontend_update',
+ {
+ name: name,
+ value: { args: args }
+ },
+ (ack) => {
+ // Update the functionCalls state with the new call if we get an acknowledge msg
+ if (ack !== undefined) {
+ setFunctionCalls((prevCalls) => [...prevCalls, { name, args, result: ack }]);
+ }
+ }
+ );
+ };
+
+ useEffect(() => {
+ renderCount.current++;
+ if (props.hideOutput !== undefined) {
+ setHideOutput(props.hideOutput);
+ }
+ });
+
+ const args = Object.entries(props.parameters).map(([name, type], index) => {
+ const form_name = `${name} (${type})`;
+ return (
+
+ {form_name}
+
+
+ );
+ });
+
+ return (
+
+
Render count: {renderCount.current}
+
setHideOutput(!hideOutput)} style={{ cursor: 'pointer' }}>
+ Function: {name}
+
+
+
+
+
+
+ {functionCalls.map((call, index) => (
+
+
+ {Object.entries(call.args)
+ .map(([key, val]) => `${key}=${JSON.stringify(val)}`)
+ .join(', ') +
+ ' => ' +
+ JSON.stringify(call.result)}
+
+
+ ))}
+
+
+
+ );
+});