How many times should a block’s edit be being called?


It feels like the answer should be once, or maybe once per instance of the block on a post/page.

I’m writing a new block, and for debugging purposes, I’m logging the post_id very early in my block’s edit function. I notice if I add an instance of the block to a post, it gets logged 4 times; if I add 2 or more instances, it gets logged at least 6 times.

Is this expected behavior? If not, where should I be looking? My top guesses are:

  1. I’m doing something with both PHP/JS and doing ServerSideRender; maybe I’m not supposed to be registering the block on both the PHP and JS side?

  2. Maybe I’m hooking into the wrong actions? (currently, init)?

  3. Maybe I’m doing something terrible in my JS that’s causing it to reload/re-render a bunch (I hope not this, as I’m new to JS and it will take forever to find).

or, maybe it is OK that it’s getting called a gazillion times.

philolegein 1 month 0 Answers 24 views 0

Leave an answer