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
},
}
);
Generated using TypeDoc
withLifecycle
is a utility function that adds lifecycle hooks to a Cardboard tag.Will call
handler.mounted
when the element is added to the DOM.Then call
handler.beforeUnmount
before the element is removed from the DOM.Finally call
handler.unmounted
when the element is removed from the DOM.