fix: 清理后台开发态 React 警告
This commit is contained in:
1 parent
3af5611da5
commit
34504c0b44
8 files changed
+42
-9
No files matched your search
@@ -28,8 +28,9 @@ export function InquiryPreviewEditor({
|
||||
const record = query.data?.find((item) => item.id === runtime.key);
|
||||
const field = runtime.fields.find((item) => item.key === fieldKey);
|
||||
useEffect(() => {
|
||||
if (field) form.setFieldsValue({ ...field });
|
||||
}, [fieldKey, runtime.key, form]);
|
||||
if (!record || !field) return;
|
||||
form.setFieldsValue({ ...field });
|
||||
}, [field, fieldKey, form, record, runtime.key]);
|
||||
const update = (values: Record<string, unknown>) =>
|
||||
runtime.fields.map((item) => (item.key === fieldKey ? { ...item, ...values } : item));
|
||||
const save = useMutation({
|
||||
|
||||
@@ -173,6 +173,7 @@ export function PresentationEditorInspector({
|
||||
</div>
|
||||
) : (
|
||||
<PresentationFormPanel
|
||||
key={`${selectedPage}:${selectedTarget.key}`}
|
||||
form={form}
|
||||
initialValues={initialValues}
|
||||
editableSections={editableSections}
|
||||
|
||||
@@ -146,7 +146,7 @@ export function TemplatePreview({
|
||||
<>
|
||||
{!ready && !error ? (
|
||||
<div className="template-preview__loading">
|
||||
<Spin tip="正在加载页面预览" />
|
||||
<Spin description="正在加载页面预览" />
|
||||
</div>
|
||||
) : null}
|
||||
{error ? (
|
||||
|
||||
@@ -348,14 +348,13 @@ export function usePresentationEditorController({
|
||||
(page: string) => {
|
||||
guardDraft(() => {
|
||||
setBrandDirty(false);
|
||||
form.setFieldsValue(initialValues);
|
||||
resetPreview();
|
||||
setRecordDraft(undefined);
|
||||
setInquiryDraft(undefined);
|
||||
setActivePage(page);
|
||||
});
|
||||
},
|
||||
[guardDraft, form, initialValues, resetPreview],
|
||||
[guardDraft, resetPreview],
|
||||
);
|
||||
const selectDetailOffering = useCallback((id: string) => {
|
||||
setDetailOfferingId(id);
|
||||
|
||||
@@ -89,7 +89,6 @@ export function useBrandPresentationForm({
|
||||
return values;
|
||||
}, [brand, config, sections]);
|
||||
|
||||
useEffect(() => form.setFieldsValue(initialValues), [form, initialValues]);
|
||||
return { form, initialValues };
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,21 @@ const element = (tag) =>
|
||||
|
||||
export const View = element("div");
|
||||
export const Text = element("span");
|
||||
export const Button = element("button");
|
||||
export const Button = React.forwardRef(
|
||||
({ children, className, style, onClick, loading, ...props }, ref) =>
|
||||
React.createElement(
|
||||
"button",
|
||||
{
|
||||
...props,
|
||||
ref,
|
||||
className,
|
||||
style,
|
||||
onClick,
|
||||
...(loading ? { "aria-busy": "true" } : {}),
|
||||
},
|
||||
children,
|
||||
),
|
||||
);
|
||||
export const Input = React.forwardRef(({ onInput, ...props }, ref) =>
|
||||
React.createElement("input", {
|
||||
...props,
|
||||
|
||||
Reference in new issue
Block a user