Skip to content

Update to build against React 19 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

anjackson
Copy link

This PR attempts to upgrade the dependencies of this widget so it can run in the most recent release of DecapCMS (3.7.1) which uses React 19. Running in dev mode, this seems to work as expected.

However, when trying to import this module and use it with the version of DecapCMS installed in an admin page, e.g. using

npm run build
cp dist/index.js {TARGET_LOCATION}

Then...

 <body>
    <script>
      window.CMS_MANUAL_INIT = true
    </script>
    <!-- Include the script that builds the page and powers Decap CMS -->
    <script type="text/javascript" src="https://unpkg.com/decap-cms@^3.0.0/dist/decap-cms.js"></script>
    <script type="text/javascript" src="./index.js"></script>
    <script type="module">
      CMS.registerWidget('create-select', window.CreatableSelectControl, window.CreatableSelectPreview)
      CMS.init();
    </script>

I get an error when attempting to view the widget:

TypeError: Cannot read properties of null (reading 'useState') at t.useState

Which is being thrown in react-state/creatable, I think.

I am not an experienced React developer, so I may well be making some kind of basic mistake. Apologies if so.

@anjackson
Copy link
Author

Well, the version that seemed to work was actually the local dev version when running under vite (https://github.com/anjackson/decap-cms-widget-create-select/tree/use-vite). After having set the thing up to run under webpack, the same error happens when viewing the widgets after running npm run start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant