I want to perform certain action, when gutenberg block is removed or new gutenberg block is added in post editor.

How do i add lister to this two event in gutenberg javascript ?

Thank you

  • what is it that you want to do when this happens? It is necessary to know to answer your question correctly ( it may also be the incorrect approach to what you're trying to do ). What is the problem this solves for you?
    – Tom J Nowell
    Sep 13 at 9:23
  • thank you for your reply. consider I want to create log for added and removed blocks. Sep 13 at 9:27
  • so if somehow i can trigger function call on block remove and new block addition, where i can get block details, that would be great. Sep 13 at 9:29
  • you can subscribe to the store which can update you when things change, but you would need to figure out if that meant a block was added or if a block was removed
    – Tom J Nowell
    Sep 13 at 9:34
  • That is the issue, I can call componentDidUpdate on something gets changed on editor. But i need something from where i can identify block is removed or added. Sep 13 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.