Hello there @Abrar!
Let me give you an example on what I am using on my projects, whenever I want to dynamically render UI elements based on mobile breakpoints.
I usually use the afterRender
and afterNextRender
functions which allows me to register a render callback.
afterNextRender
)afterRender
).Code example:
//
constructor() {
afterNextRender(() => {
this.someMethod1();
this.someMethod2();
});
}
// Client-side exclusive functionality
someMethod1() {
console.log('window object is not undefined anymore!', window);
}
someMethod2() { ... }
//