const myTag = withLifecycle(
div('Hello World'),
{
mounted: (tag) => {
console.log('Mounted:', tag);
return true; // or false to prevent mounting
},
unmounted: (tag) => {
console.log('Unmounted:', tag);
},
beforeUnmount: (tag) => {
console.log('Before Unmount:', tag);
return true; // or false to prevent unmounting
},
}
withLifecycleis a utility function that adds lifecycle hooks to a Cardboard tag.Will call
handler.mountedwhen the element is added to the DOM.Then call
handler.beforeUnmountbefore the element is removed from the DOM.Finally call
handler.unmountedwhen the element is removed from the DOM.