Multi step form or conditional rendering with DevTool console get an error Cannot update a component (`FormItemTest`) while rendering a different component (`FormItemTest`). To locate the bad setState() call inside `FormItemTest`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react, typescript
- Lĩnh vực
- devtools
Hướng nghiên cứu
Start with the provided Demo reproduction using FormProvider, conditional Step2 rendering, getStep(step), and . Reproduce the warning with DevTool enabled, then inspect the DevTool component and its control subscription or rendering path. Done means the multi-step example no longer reports the setState-during-render warning while DevTool remains enabled.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The collection of fields in react hook form meets expectations. Confirmed to be a bug in DevTool. when I annotate DevTool,no more errors reported.
this is example code
import {
useForm,
FormProvider
} from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { DevTool } from '@hookform/devtools';
import FormItemTest from '~/components/form/FormItemTest';
import {
useState
} from 'react';
import * as z from 'zod';
const schema = z.object({
step1: z.string(),
step2: z.string()
});
function Step1() {
return (
<FormItemTest name='step1' />
)
}
function Step2() {
return (
<FormItemTest name='step2' />
)
}
function getStep(step: number) {
switch (step) {
case 0:
return <Step1 />;
case 1:
return <Step2 />;
default:
return null;
}
}
export default function Demo() {
const [show, setShow] = useState(false);
const [step, setStep] = useState(0);
const methods = useForm({
resolver: zodResolver(schema),
mode: 'onChange'
});
const onSubmit = methods.handleSubmit(values => {
console.log(values);
});
return (
<div>
<FormProvider {...methods}>
<form>
<Step1 />
{show && <Step2 />}
{getStep(step)}
</form>
</FormProvider>
<DevTool control={methods.control} />
<button onClick={() => setShow(s => !s)}>Toggle Step2</button>
<button onClick={onSubmit}>Submit</button>
<button onClick={() => setStep(s => s + 1)}>Next Step</button>
</div>
)
}
- Ngôn ngữ chính
- TypeScript
- Star
- 670
- Fork
- 55
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của react-hook-form/devtools
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
react-hook-form/devtools#234 · 1 bình luận · 5 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
react-hook-form/devtools#223 · 2 reaction ·
-
DevTools in production Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
react-hook-form/devtools#212 · 5 bình luận · 8 reaction ·
-
issue: Warning: Cannot update a component (`DevTool`) while rendering a different component. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
react-hook-form/devtools#208 · 13 bình luận · 21 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
react-hook-form/devtools#207 · 6 bình luận · 1 reaction ·
Tất cả issue của react-hook-form/devtools
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
copse-dev/agent-pane#2953 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
[Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity Đang mởbug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Client support matrix inclusion Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
calcite-components needs triage refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Esri/calcite-design-system#15203 ·