Type alias ExecuteProp<ELEM>

ExecuteProp<ELEM>: ((element) => void)

provide a function to execute on the generated output of an HyperRender.h | Element Renderer as the first argument.
this is useful in cases where you may wish to register the element post-creation, or perhaps apply some mutations to the element itself.
or, declare a "on delete" function to execute when the element is being permanently detached. ideally, you should run any cleanup tasks here.

Type Parameters

  • ELEM = Element

Type declaration

    • (element): void
    • Parameters

      Returns void

Example

// apply some style to `my_div` post-creation
const my_div = <div style="background-color: green;" {...{
[ONINIT]: (div_element): void => {
if(div_element.style.backgroundColor === "green") {
div_element.style.backgroundColor = "red"
}
if(div_element.style.backgroundColor === "red") {
div_element.style.backgroundColor = "blue"
}
} as ExecuteProp<HTMLDivElement>
}}>
I'm blue daba dee daba die, If I were green I would die.
</div>

Example

// log when the div element has been destroyed
const my_div = <div style="background-color: green;" {...{
[ONCLEAN]: (div_element): void => {
console.log("eiffel 65 turned green, and died")
} as ExecuteProp<HTMLDivElement>
}}>
I'm blue daba dee daba die, If I were green I would die.
</div>

Generated using TypeDoc