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:
-
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?
-
Maybe I’m hooking into the wrong actions? (currently,
init
)? -
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.
Leave an answer
You must login or register to add a new answer .