Skip to Content
Author's profile photo David Stocker

The Custom Component init event and when it runs

A few times now, partners have asked me why their custom components seem to execute the init event at unexpected times. The answer is actually very simple. While you might expect the event to run exactly once, when the component is first initialized, this is not quite the case. This event runs when the component is initialized in the html DOM. Design Studio 1.x and Lumira 2.x are thrifty with the DOM. It is built dynamically, as needed and if the components is hidden from view – e.g. by explicitly hiding it or if it is in a pagebook, storybook or tabstrip and another page is brought into focus – then the component is removed from the dom. When the user brings the component back into view, the init event executes.


Properties ARE persisted, so if you have init event code that you really only ever want to have executed on the first run, implement a hidden property to keep track of whether or not the current call is the first. E.g you could set it with the default value of 0 and check for that in the init event. If it is 0, then execute your ‘first execution’ code and then increment it.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.