React-slick: Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null

Created on 6 Jul 2016  路  12Comments  路  Source: akiran/react-slick

I am creating a slider it does render the component and the styles however I do get a js error:

Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null

the code is:

render()
    {
        var settings = {
            dots: true,
            infinite: true,
            speed: 500,
            arrows: false,
            autoplay: true,
            slidesToShow: 3,
            centerMode: true
        };

        return (
            <Slider {...settings}>
            {
                ObjectToArray.toArray(this.props.winners).map(function (raw, i) {
                    let winnerData = raw.value;

                    return (
                        <div>
                            <Winner userName={winnerData.userName}
                                    sex="male"
                                    rank={winnerData.rank}
                                    game={winnerData.game}
                                    date={winnerData.createdOn}
                                    winnings={winnerData.winnings}
                                    userRank={winnerData.userRank}
                            />
                        </div>
                    );
                }.bind(this))

            }
            </Slider>
        );
    }

when dragging the items they seem to collapse and the following error occures:

recently-won.react.js:5636 Keys Missing Object {slideIndex: 0, trackRef: undefined, className: "", adaptiveHeight: false, arrows: false鈥

any idea?

Most helpful comment

I have degrade the version of react-slick from 0.14.5 to 0.13.6. and it works for me.

All 12 comments

Do we have the fix / workaround for this ?
The moment I load the template with "Slider" tag in it. It complains
Cannot read property 'getBoundingClientRect' of null
line 743 of react-slick.js
var trackWidth = this.getWidth(_ReactDOM2['default'].findDOMNode(this.refs.track));

Seeing the same issue. Any word?

Also seeing this issue. I think it only occurs when the slides are dynamically generated.

The solution here, fixed it for me.
https://github.com/akiran/react-slick/issues/328

Can everyone try solution provided in #328 fixes your issues as well.

If you still see this issue, can you provide a jsfiddle demo replicating the issue

i managed to sove it like this:
<Slider ref="simpleSquare" {...settings}> {this.state.items || <div></div>} </Slider>

So I solved it like this:



Wrap the dynamic slide component with

, such as

I have degrade the version of react-slick from 0.14.5 to 0.13.6. and it works for me.

Ran into this issue, #328 "fixed" it for me as well.

This was happening for me because I didn't pass anything to the component, so I just created a wrapper to check if no children are passed.

On further inspection, it was when passing a react element rather than a DOM element, doesn't work but

Even though I have wrapped inner components inside div, I'm getting this error.

The stack trace shows the parent call happened in this.update() invoked from componentWillReceiveProps.

Anyone facing similar issue?

I tried to throttle CPU to test if it is related to performance, but no luck in reproducing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

will88 picture will88  路  3Comments

darkalor picture darkalor  路  4Comments

slashwhatever picture slashwhatever  路  3Comments

PolGuixe picture PolGuixe  路  3Comments

amishPro picture amishPro  路  3Comments