wadackel / react-stack-grid

Pinterest like layout components for React.js
https://wadackel.github.io/react-stack-grid/
MIT License
869 stars 77 forks source link

Error in client console: Infinity is an invalid value for the height css style property #46

Open harrisonlo opened 6 years ago

harrisonlo commented 6 years ago

Complete error in Chrome console:

Warning: `Infinity` is an invalid value for the `height` css style property.

Check the render method of `TransitionGroup`.

It didn't locate where that error comes from. It's simply a warning.js error. I'm getting this message after using react-stack-grid.

xfumihiro commented 6 years ago

Interestingly, the warning only shows when render stackgrid inside react-swipeable-views in my case.

polad commented 6 years ago

We have the same issue

gpinhey commented 6 years ago

The root of this issue is based on ctrlplusb/react-sizeme#120 where element-resize-detector injects a div into the DOM at a very low level, bypassing React. This causes react-sizeme to return a width of 0 for that instant when the DOM under react-stackgrid's node only consists of a 0-width div, so react-stackgrid lays out elements with 0 columns, resulting in a divide by 0.

This bug is ultimately harmless, as once React has a chance to mount the actual children as DOM nodes, react-sizeme re-evaluates and passes a non-zero width, so everything works out fine.

A zero check here should fix the warning message: https://github.com/tsuyoshiwada/react-stack-grid/blob/25e61df87d7ad112a1873a83899d53aa48b079a7/src/components/StackGrid.js#L225

bilicio commented 6 years ago

Change the line 425 on the newer version of the file StackGrid.js, put any value of height instead of 0.

Cantinaband commented 5 years ago

I had the same issue with react@16.8.4 and react-stack-grid@0.7.1.

Solved it by changing line 487 to:

var height = columnHeights.length ? Math.max.apply(Math, _toConsumableArray(columnHeights)) - gutterHeight : 0;

indu95 commented 3 years ago

I'm using "react": "^17.0.0", "react-stack-grid": "^0.7.1", and this issue still persists and I see there is lag on screen because of this error, can anyone please let me know the solution how to resolve this? or any workarounds? @Cantinaband

Guaaan commented 2 years ago

I'm having the exact same problem on react "^18.2.0", "react-stack-grid": "^0.7.1". Has someone found a solution yet?

osomaher2020 commented 1 year ago

I've faced the same problem, and found the issue was the [array of elements] to be shown in the Slider is empty [ ] So I enclosed the Slider by (items.length) condition like:

(items.length) &&
<>
    <Slider {...settings} className="pb-sm-5 mb-5 slick-slider-wrapper">
          .....................
    </Slider>
</>

Hope this may help

CeciliaJorcin commented 1 year ago

I've faced the same problem, and found the issue was the [array of elements] to be shown in the Slider is empty [ ] So I enclosed the Slider by (items.length) condition like:

(items.length) &&
<>
    <Slider {...settings} className="pb-sm-5 mb-5 slick-slider-wrapper">
          .....................
    </Slider>
</>

Hope this may help

solved the problem for me! Thank you @osomaher2020! I was getting client.js:1 Warning: NaN is an invalid value for the width css style property.