mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-28 00:14:21 +00:00
fix: kbform react error
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
@@ -242,11 +242,17 @@ export default function KBForm({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Convert creation schema to dynamic form items (same as ExternalKBForm)
|
// Convert creation schema to dynamic form items (same as ExternalKBForm)
|
||||||
const configFormItems = parseCreationSchema(selectedEngine?.creation_schema);
|
// Memoize to avoid regenerating UUIDs on every render, which would cause
|
||||||
|
// DynamicFormComponent's useEffect to re-fire and trigger an infinite loop.
|
||||||
|
const configFormItems = useMemo(
|
||||||
|
() => parseCreationSchema(selectedEngine?.creation_schema),
|
||||||
|
[selectedEngine?.creation_schema],
|
||||||
|
);
|
||||||
|
|
||||||
// Convert retrieval schema to dynamic form items
|
// Convert retrieval schema to dynamic form items
|
||||||
const retrievalFormItems = parseCreationSchema(
|
const retrievalFormItems = useMemo(
|
||||||
selectedEngine?.retrieval_schema,
|
() => parseCreationSchema(selectedEngine?.retrieval_schema),
|
||||||
|
[selectedEngine?.retrieval_schema],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Show loading state
|
// Show loading state
|
||||||
|
|||||||
Reference in New Issue
Block a user