I am using justifiedGallery for my webpage. When I first visited the page, the gallery displayed correctly. But when I reload the page, it will break.

I use a meteorite and react.
Example of old code:
$(document).ready(() => {
$('#gallery').justifiedGallery({
rowHeight: 400,
fixedHeight: false,
lastRow: 'justify',
margins: -3,
});
});
I put it in jQuery setTimeOut () function.
setTimeout(function(){
$('#gallery').justifiedGallery({
rowHeight: 400,
fixedHeight: false,
lastRow: 'justify',
margins: -3,
});
}, 100);
Now it works fine. I just need to know what is the correct way to fix it? This is for future proof.
user6037606
source
share