Comments (10)
I added reference to my Masonry instance using the following code
ref={function(c) {this.masonry = c.masonry;}.bind(this)}
and now can manually trigger resize using the following code
this.masonry.layout()
Hope this helps.
from react-masonry-component.
fixed in [email protected]
from react-masonry-component.
If anyone has a solution that keeps the existing functionality and fixes this then feel free to send a PR! This component is a bit hacky from the start actually, so a hacky solution that is encapsulated in the Masonry component (not leaking out) is better than no solution :-)
from react-masonry-component.
If anyone is still trying to figure this out, the new way to do this is:
<Masonry enableResizableChildren>{ children }</Masonry>
from react-masonry-component.
I had the same problem. As far as I can see, the only way is to change a props of Masonry (any, even if it doesn't exist), to force a reload (the component triggers a reloadItems
on ComponentWillReceiveProps
. Not perfect, but this is the same thing (IIRC) with Masonry in general (not about this component), even with vanilla JS, you still need to trigger the refresh.
from react-masonry-component.
so my very hacky solution was to expose the performLayout function of React-Masonry and call it whenever I needed a refresh. It works but not very elegant.
from react-masonry-component.
I managed to work around this by simply setting state in the component that has <Masonry />
in it's render method (didn't need to pass the state as prop, even)
from react-masonry-component.
@t1mmen's approach works, though this is clearly still a hacky approach.
from react-masonry-component.
Facing the same issue. Unable to figure out a solution yet. Put this on stackoverflow also for more ideas http://stackoverflow.com/questions/34411211/reload-react-masonry-component-manually
from react-masonry-component.
hi, also encountered this issue and i used @erkartik91's solution and it worked.
anyway,
i am using this library: https://github.com/puikinsh/Adminator-admin-dashboard which uses react-masonry-component too as i've looked into my node_modules folder. according to the changelog, it's version is 6.2.0.
last comment here says it's fixed even in the earlier version (4.3.0), but i wonder is it really fixed in the update? because i still encountered this same issue.
thank you.
from react-masonry-component.
Related Issues (20)
- Masonry slide effect does not work HOT 2
- Small Bug HOT 2
- Is there any way to animate fading out elements on update?
- RTL Support HOT 1
- How to centre the images? HOT 1
- onImagesLoaded is being called twice HOT 1
- Is it possible to show different widths? HOT 1
- A simple CodeSandbox image gallery example
- Update to React 17 HOT 4
- What are the masonry options properties? HOT 2
- Need Help: Not able to add gutter between the cards.
- Demo not working? HOT 3
- Masonery not correctly layout because force to have invisible columns
- how to fix 'Image elements do not have explicit width and height' in pageSpeed
- Support React 18 HOT 2
- Add support for Scss/css module .
- it works only very first time and then it loses position HOT 1
- I seem to have no control over the height of the masonry component HOT 1
- Live Link
- StrictMode breaks Masonry HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-masonry-component.