Detect Render
Advanced and fine rendering techniques
Introduction
Solution - ref & subscriptions
import { render, State } from '@weblabsjs/core'
function App() {
const element = State() //initially undefined
element.subscribe("set:after", (value) => {
//this function will be called iff the element was registered
//now you can use the value to do some stuff
console.log( value.coreElement ) //prints the real element.
})
return div(
p("Hello world")
).ref( element ) //store this component to the element state
}Last updated