[bug]: Custom Field Functions in Dev Mode but Fails in Start Mode

Đang mở
#29 3 bình luận 2 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 6 ngày

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
sqlite, typescript
Lĩnh vực
frontend, tooling

Hướng nghiên cứu

Reproduce the generated custom field with the stated Strapi and TypeScript setup in dev and start modes, then compare where useField obtains the Form context. Trace the generated field and start-mode initialization path; done means the custom field works without the Form-component error in start mode.

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

Mô tả

issue: bug severity: medium source: sdk-plugin
What version of @strapi/blocks-react-renderer are you using?

Node.js version: 18.17.0
NPM version: yarn/1.22.19
Strapi version: 5.0.0-rc.5
Database: sqlite
Operating system: darwin-arm64
Is your project Javascript or Typescript: Typescript
Plugin language: Typescript

What's Wrong?

The custom field works in dev mode but fails in start mode due to the useField hook not being able to find the Form context. This error (Uncaught Error: The Form Component has not been initialised, ensure you are using this hook within a Form component) indicates that the Form component or context provider is not properly initialized in start mode. This discrepancy often arises from differences in the build or initialization process between development and production environments.

To Reproduce

Add a custom field using the latest (5.0.1) plugin generator and try to use the useField helpers in both dev and start modes. In dev mode, everything works as expected. However, in start mode, you encounter the following error:

Uncaught Error: The Form Component has not been initialised, ensure you are using this hook within a Form component

This indicates that while the custom field functions correctly in dev mode, it fails in start mode due to the Form component or context not being properly initialized.

Expected Behaviour

No errors regarding custom field.

Ngôn ngữ chính
TypeScript
Star
24
Fork
13
Merge trung bình
5 ngày 3 giờ
Pull request đã merge (30 ngày)
5

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 strapi/sdk-plugin

Tất cả issue của strapi/sdk-plugin

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.