ahmadawais / create-guten-block

📦 A zero-configuration #0CJS developer toolkit for building WordPress Gutenberg block plugins.
https://Awais.dev/cgb-post
MIT License
3.15k stars 328 forks source link

Using external component breaks Gutenberg #270

Open theOnlyLuxios opened 4 years ago

theOnlyLuxios commented 4 years ago

Hi everyone ! I love this plugin and I think it can be quite powerful but I'm encountering an issue that is blocking me. I want to use Material-UI react library to help me create blocks. When I import it and use it in the save method of a block, I have this 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: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. 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.

Yet, when I use it on an edit function, everything works smoothly. Just wondering how I could do that ?

Thanks everyone !

pwkip commented 4 years ago

I think this might be the answer you are looking for: https://github.com/WordPress/gutenberg/issues/16843#issuecomment-517301811

mallgrab commented 3 years ago

So the only way to use external components would be to make the block be dynamic?