Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When removing an item from FluidGrid, it causes a clientHeight error #8

Open
KevinGhadyani-minted opened this issue Nov 19, 2019 · 2 comments

Comments

@KevinGhadyani-minted
Copy link

If I delete an item from the grid (for instance, an image in a photo gallery), it seems to be thinking that element still exists and causes a "can't find .clientHeight of undefined" error.

image

This might have something to do with it storing children locally and then not looking for changes in children when an update occurs.

@KevinGhadyani-minted
Copy link
Author

Actually, that code appears to already exist:
https://github.com/AntonRublev360/react-fluid-grid/blob/master/src/FluidGrid.js#L34

image

So now I'm not sure what's causing this.

@KevinGhadyani-minted
Copy link
Author

KevinGhadyani-minted commented Nov 19, 2019

I traced this further. We're pulling this.items, but we're not updating this value after this.props.children has changed even if everything else is being recomputed.

We end up in a situation like this where this.items has a null element:
image

A quick fix would be to filter out null elements from items in this.arrangeItems(). A proper fix would be to add another function which recomputes this.items after componentDidUpdate before initializing columns etc.

Maybe call this.renderChildren() first on componentDidUpdate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant