Site icon Hip-Hop Website Design and Development

Run code as soon as when block is created

I am growing a customized plugin with react and I want to create a novel identifier for every new added occasion of my customized block as quickly as it’s added to the web page.

So I add my "custom block" and the code runs as soon as to create and assign the id. Once I go to the backend once more, the code shouldn’t run once more. But when I add a brand new occasion of my "custom block", the code runs as soon as once more for this occasion and creates & assigns a brand new id.
So I assume I am in search of a hook like "blockAddedToPage" or so, however I am unable to discover one thing matching.

I do know that there’s the clientid, however I want one thing everlasting and shorter 😀

I wrote a small helper perform to create my id, however how do I run it solely when the block is added to the web page?