eiriklv / react-masonry-component

A React.js component for using @desandro's Masonry
MIT License
1.44k stars 145 forks source link

Console warning: forcedUpdate #1

Closed t1mmen closed 9 years ago

t1mmen commented 9 years ago

Hi,

Thanks for this component! I'm having a slight issue when navigating away from pages using this component, with the console giving me the following warning:

Warning: forceUpdate(...): Can only update a mounted or mounting component. This usually means you called forceUpdate() on an unmounted component. This is a no-op.
t1mmen commented 9 years ago

I've tried removing the forcedUpdate call in the componentWillRecieveProps hook, which fixed the warnings issue. Everything still appears to be working as expected, but I'm thinking you probably had a good reason to put this call in?

eiriklv commented 9 years ago

Hi @t1mmen! There's a reason for it (there's some quirks when you use infinite scrolling/reloading of entire collections in certain cases). But to mitigate the warning I've released a fix that checks if the component is mounted (this.isMounted) before doing this.forceUpdate. Released as 1.0.3 :-)