vanjs-org / van

🍦 VanJS: World's smallest reactive UI framework. Incredibly Powerful, Insanely Small - Everyone can build a useful UI app in an hour.
https://vanjs.org
MIT License
3.77k stars 87 forks source link

Lifecycle event: mount and unmount #245

Closed sirenkovladd closed 7 months ago

sirenkovladd commented 7 months ago

For example for library leaflet I need to initialize the map after mounting to dom, because this function calculates the block size from the actual size on the page also if i leave the page a good practice is to unmount the map, this removes the listeners

Correct example on vue https://jsfiddle.net/Sirenko/6oLkfj49/59/

example with errors on VanJs https://jsfiddle.net/Sirenko/uvpk4t0g/39/

Tao-VanJS commented 7 months ago

You can leverage setTimeout to achieve the effect.

I just modified your example to make it work: https://jsfiddle.net/8xj47fga/1/