Skip to content

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

Open
@burakozdemir32

Description

@burakozdemir32

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    To be reviewed (Open)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions