destroy() fires error after second mount() call
See original GitHub issueHi! Thanks for very useful plugin! I founded some bug in Event Binder I try to mount Glide on small screens and destroy on large screens. When, Glide was mounted after first destroy(), on second destroy() Glide fire error in console and destroy doesn’t work There is fiddle
There is my code
window.addEventListener('resize', () => {
if( window.innerWidth < 1200 ) {
glide.mount();
} else {
glide.destroy();
}
});
Also, if I set {type: ‘carousel’} Glide creates new clones with every attempt to call destroy()
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:8 (1 by maintainers)
Top Results From Across the Web
how to destroy or block mount events in mounted() vuejs
After re-open it(from second mount), it just keep triggers all the event and I have to block it. Is there a way that...
Read more >useEffect(fn, []) is not the new componentDidMount()
The return value of render() is used to mount new DOM. componentDidMount fires and sets state immediately (not in an async callback); The...
Read more >The last guide to the useEffect Hook you'll ever need
Unmounting the child component leads to an error. The child component has registered an interval that invokes a function every second. However, ...
Read more >Lifecycle hooks - Angular
The SpyDirective implements the ngOnInit() and ngOnDestroy() hooks, and uses them to watch and report when an element goes in or out of...
Read more >A Complete Guide to Vue Lifecycle Hooks - with Vue 3 Updates
mounted() and onMounted(). Called right after the first render of the component. The element is now available allowing for direct DOM access.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I encountered the same issue when I tried to swap the slides and in doing so I was using destroy() and mount(). What I figured is that when you use the destroy() method, the listener property is removed and is not set when you call mount() after that. So any destroy() call will throw the error.
As a workaround, I created a new Glide object instead of calling mount() on the existing one.
instead of:
I did this:
I think
mount()
is not the opposite ofdestroy()
and when you call destroy once, event listeners are lost. And when we call mount() again, it doesn’t re-initializes the even listeners. May be ainitialize()
function that we can call beforemount()
could help.Yeah, same scenario, same issue.
It would be nice to use mount() and destroy() indefinitely as OP mentioned.
+1 for that.
EDIT: Or better yet, a way to disable per breakpoint.
EDIT 2: Workaround: add a control variable: