formState.isSubmitting stays true when the fetcher's submitting and idle states land in one render

Đang mở Phù hợp với người mới
#188 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu từ phần triển khai useRemixForm và tìm effect xóa isSubmittingNetwork khi isSubmittingForm là false. Tái hiện sự cố bằng một action nhanh và form fetcher sử dụng createRoutesStub; issue đưa ra thay đổi dependency được đề xuất. Hoàn thành khi formState.isSubmitting được đặt lại sau response, kể cả khi response có lỗi, và nút gửi được bật lại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

useRemixForm sets isSubmittingNetwork to true in onSubmit and only clears it in an effect that depends on [isSubmittingForm]. When the action responds quickly, React Router can apply the fetcher's submitting and idle states in a single render. isSubmittingForm then stays false the whole time, the effect never re-runs, and formState.isSubmitting stays true until the component remounts. The form's submit button stays disabled after the response, including when the response has errors.

Reproduction: a route whose action returns immediately (for example () => ({ errors: { root: { message: 'Save failed' } } })) and a fetcher form whose button uses disabled={formState.isSubmitting}. Rendered with createRoutesStub in a unit test, it reproduces every time: the error shows, but the button never re-enables. In the browser it happens when the response arrives before React renders the submitting state, which we saw with a busy main thread.

Fix we're using as a patch: also reset when new data arrives:

useEffect(() => {
  if (!isSubmittingForm) {
    setIsSubmittingNetwork(false);
  }
}, [isSubmittingForm, data]);

Seen on 7.2.1. 7.3.0 and main have the same effect.

Ngôn ngữ chính
TypeScript
Star
454
Fork
44
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của code-forge-io/remix-hook-form

Tất cả issue của code-forge-io/remix-hook-form

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.