1

So, I have a Gutenberg block that has a custom component inside, that needs to be refreshed if the dimensions of the block change. However, apparently there's no way for me to detect when the alignment attribute (wide or full) has changed.

Is there a way to listen to changes on that attribute, and run a custom callback, when needed?

Thanks!

1 Answer 1

1

Turns out that if one uses wp.data.subscribe, you're able to intercept any change that occurr in the editor. As you can imagine, this is not very performant. So I've decided to create an extra hidden attribute that stores the old alignment value for the block, and fire the callback only when that attribute and the align one are not the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.