contentful / field-editors

React components and extensions for building Contentful entry editor
https://contentful-field-editors.netlify.app/
MIT License
150 stars 118 forks source link

Struggeling to use local version of @contentful/field-editor-single-line #1524

Closed nerdess closed 11 months ago

nerdess commented 11 months ago

1) I checked out and installed this repo locally

2) I followed this instruction: https://github.com/contentful/field-editors/blob/master/CONTRIBUTING.md#integration-to-contentful-web-application (instead of cd packages/single-line I did cd packages/references and instead of yarn link '@contentful/field-editor-single-line' I did yarn link "@contentful/field-editor-reference")

But in my Contentful app I get the errors

Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
You might have mismatching versions of React and the renderer (such as React DOM)
You might be breaking the Rules of Hooks
You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

and


react-dom.development.js:18687 The above error occurred in the <MultipleEntryReferenceEditor> component:

    at MultipleEntryReferenceEditor (http://localhost:3000/static/js/bundle.js:231829:52)
    at Field (http://localhost:3000/static/js/bundle.js:756:85)
    at App (http://localhost:3000/static/js/bundle.js:56:86)
    at SDKProvider (http://localhost:3000/static/js/bundle.js:10836:33)
Bildschirmfoto 2023-10-25 um 11 00 56

What am I doing wrong?

nerdess commented 11 months ago

Fixed it by also linking react and react-dom:

on local field editor: cd /field-editors/node_modules/react yarn link cd /field-editors/node_modules/react-dom yarn link

on my contentful app: yarn link react yarn link react-dom