[bug]: Custom Field Functions in Dev Mode but Fails in Start Mode #29
Labels
issue: bug
Issue reporting a bug
severity: medium
If it breaks the basic use of the product but can be worked around
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 bothdev
andstart
modes. Indev
mode, everything works as expected. However, instart
mode, you encounter the following error:This indicates that while the custom field functions correctly in
dev
mode, it fails instart
mode due to theForm
component or context not being properly initialized.Expected Behaviour
No errors regarding custom field.
The text was updated successfully, but these errors were encountered: