-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Support for React Hooks #2026
Comments
Any way you can reproduce with a code example on a test repository? Since Hooks are still in alpha, it may take a while for review. I'm currently waiting for release before I try to tackle integration, but your example would help also. |
Sorry for the late reply. |
Yep, stable now. We'll take a PR to upgrade React packages to 16.8. |
@erquhart do you see the PR being anything other than bumping the versions? I think we should make it a priority. I will take it. |
Yep just a bump of the react packages. Sent with GitHawk |
Should it work now? I just updated the packages but still getting
Is there any release date ? Thank you very much! |
It's working as of 2.4.1 - that error means you're calling Hooks from somewhere other than the body of a function component. Sent with GitHawk |
@Knaackee you are correct. You will not be able to use hooks until we find a solution for using the same instance of react. Reopening the issue. |
I am having the same issue, my component works everywhere and with other libraries except when I use it in the I am getting the same error than the others above: react 16.8.2 |
@Neddz Is the component using hooks? If so, it will not work until we find a solution. |
@talves It is, I just wanted to confirm that this is happening to me as well and it is not a problem in the component itself. |
@erquhart I made a PR of what I am proposing for a fix. I created #2097 to have I believe this is the correct way to solve this issue. This will allow for projects to continue with hooks and for NetlifyCMS to figure out if it will create a new library for 3.0 and move the build into it's' own library. Caveat: Automatic init bundle |
On the netlify-cms-manual-init.js bundle, I would like to take the globals into the CMS global (i.e. CMS.init, CMS.createClass) and leave the createElement on the React global. @erquhart Any objections? Esentially, we would have:
|
So here's my concern: even once Netlify CMS is (eventually) completely decoupled from the SPA distribution package (with the current routing, auto bootstrap, etc), that SPA distro will still be the one most folks use. We need to support React Hooks in a way that can be used in SPA distro, otherwise we're going to end up with a fragmented ecosystem where folks find a widget they want to use, but it's incompatible with their CMS unless they go modular. Thoughts? |
Currently no-one can really create an external library (widget, preview, etc) without a duplicate React instance unless they use the I have spent quite a bit of time on this issue and the only way I can think of doing this is the way I have outlined. My # PR will not solve this issue, so I am going to close it. It would require a new library bundle and I did not have luck getting it to work inside the monorepo. |
Gotcha - thanks for your effort on this. It will remain a general priority, as shared dependencies are a blocker for a real ecosystem (community widgets, etc). |
The first step solution is now in PR #2141 and will allow us to have a module bundle that has React and ReactDOM as external peer dependencies. We will be able to close this issue once that module library is available. |
Now we will be able to patch the gatsby-plugin-netlify-cms with #2252 Will resolve any issue with using React Hooks in NetlifyCMS for Gatsby and any other custom build solution for that matter. |
@talves |
No, the new plugin is not released. They are reviewing it soon.. This is a breaking change and will require the use of |
@buz-zard that is a known warning. Thanks.
Please create a new issue if you find a problem. |
My GatsbyJS site uses React Hooks (currently in alpha).
Netlify CMS does not support React Hooks at the moment. I am getting
Any ideas?
The text was updated successfully, but these errors were encountered: