react-lazy-load
react-lazy-load copied to clipboard
remove wrapper height once loaded
I'm using the height
prop with a roughly estimated value to prevent all items from loading immediately (since their initial height is 0, as long as the images have not been loaded). once an item has loaded, I'd like to remove the height / set it to auto
.
it would be nice if the lib provided an option for this. — in the meantime, what would be the easiest way to achieve this?
I agree, it would make sense to unset the height
prop once the component is visible (and just let the rendered component take up as much space as it needs).
In the meantime, it also works to just set/unset the height
via CSS as a workaround. LazyLoad already assigns the required classnames for this (I use JSS syntax):
'.LazyLoad': {
height: 100, // or whatever your estimated height might be
},
'.LazyLoad.is-visible': {
height: 'auto',
},