How to dynamically add style tags to Gutenberg editor in react
How to dynamically add style tags to Gutenberg editor in react
How to dynamically add style tags to Gutenberg editor in react
The problem is here: useEffect( () => { if ( ref.current ) { var panzoom = Panzoom(ref.current, { minScale: 1.1, maxScale: 5, startScale: 1.1, animate: true, duration: 1000, origin: ‘50% 0’ }); } }, []); useEffect runs again when the dependencies parameter changes, but by providing none it will only run once. If you want … Read more
Okay, just lucked upon an answer. Added const { element: { useState, }, } = wp; at the top of the file, it seemingly works, though I still have no idea what is going on.
What is the proper way of using React Hooks in Gutenberg on frontend?
You forgot to declare the attributes: registerPlugin( ‘page-layout-plugin’, { icon: ‘smiley’, attributes: { ‘showSidebarAttribute’: {‘type’: ‘boolean’, ‘default’: true}, // <– and maybe others }, render: ( props ) => { You can drop the quotes of the properties, of course (they are optional), I keep them because the equivalent statement is copied over from the … Read more
How do i fix type error
I tried your view script, i.e. the code in your view.js file, and it’s true that I also got the same error in question. However, I spotted another error which appeared before the other error, and which explained why that other error appeared: Warning: Invalid hook call. Hooks can only be called inside of the … Read more
That’s not how blocks work, the save component generates static HTML, so you can’t use interactive hooks or state. The important part is that the save component only runs inside the editor on your browser. It does not run in the database, or on the client. You can’t save a react component to the database … Read more
adds an admin menu page with a div that React replaces, but the localization inside this React doesn’t work Actually, since you are enqueueing the same script (build/index.js), which is automatically registered by register_block_type(), then in your my_enqueue_admin_scripts() function, just do wp_enqueue_script( ‘my-block-local-editor-script’ ) to enqueue/load the script on your admin menu page. And secondly, … Read more
How to add more elements to an already existing section in Gutenberg