question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

is there an "isMounted" property / mount() called on a Glide object thats already mounted causes slides to duplicate

See original GitHub issue

Doesn’t seem like it. As per multiple issues re: the calculation of the layout during paint (my comments: https://github.com/glidejs/glide/issues/508#issuecomment-687353604), I just want to construct and mount my Glide slider once after a bootstrap modal has fired the “shown” event. As per https://github.com/glidejs/glide/issues/376, doing a destroy() on the “hidden” event causes subsequent errors for “this.listeners is undefined”:

Uncaught TypeError: this.listeners is undefined
    node_modules glidejs/glide/dist/glide.esm.js?:1950
    node_modules glidejs/glide/dist/glide.esm.js?:2005
    node_modules glidejs/glide/dist/glide.esm.js?:2014
    node_modules glidejs/glide/dist/glide.esm.js?:555
    node_modules glidejs/glide/dist/glide.esm.js?:554
    node_modules glidejs/glide/dist/glide.esm.js?:698

It got me thinking that I really only need to mount it once, because if they open/close it’ll be the same slider, whatever. Of course, calling mount() on a slider thats already been mounted causes it to double its slide clones and screw up the index/order of the slides. So there’s nothing in mount() to check to see if a Glide object is initialized, and there doesn’t seem to be anything through a console.log dump that jumps out as an “is mounted” property. For my purposes, a local variable is sufficient, but it seems odd that I wouldn’t be able to access a Glide object and have access to whether or not its mounted - makes it hard to grab that stuff dynamically, and it seems like the base implementation of mount() could really benefit from being able to access that property and choose whether to mount or not.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tomgreenhillcommented, Feb 25, 2022

Thanks for the info @jedrzejchalubek, much appreciated and fully understand!

0reactions
jedrzejchalubekcommented, Feb 25, 2022

@tomgreenhill Yeah, trying to keep Glide as much agnostic to single-use cases as it can be and provide tools to control it outside (the term for that is IoC). If something can be easily done via API it should not be a part of the core.

It is easy to add it, but this part of the code will be needless for 90% of other folks that use Glide and only add weight to its scripts 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

isMounted is an Antipattern – React Blog
Specifically, calling setState() in an unmounted component means that your app is still holding a reference to the component after the component ...
Read more >
Why does mount happen over an existing directory?
Mounting a filesystem takes a directory inode and sets a flag on the kernel's in-memory copy to say "actually, when looking for the...
Read more >
React - animate mount and unmount of a single component
All I want to do is animate the mounting & unmounting of a React component, that's it. Here's what I've tried so far...
Read more >
React Native Component Lifecycle - Netguru
Just after render() is finished, the component is mounted to the DOM and another method is called — componentDidMount().
Read more >
Options - Glide.js
A dependency-free JavaScript ES6 slider and carousel. It's lightweight, flexible and fast. Designed to slide. No less, no more.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found