question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

updateSizes function fails when mounting again

See original GitHub issue

The problem underlying problem is that this.item1… this.itemN (created by refs callback in render) are null when mounting the component again, but only in certain scenarios.

I have verified that the items are set and selectedItem points to a valid item.

The error comes from this line: var itemSize = isHorizontal ? firstItem.clientWidth : firstItem.clientHeight;

Uncaught TypeError: Cannot read property ‘clientWidth’ of null at Object.updateSizes (app.min.js:85207) at Object.setMountState (app.min.js:85216)

firstItem is null because in the line var firstItem = ReactDOM.findDOMNode(this.item0); the item0 is undefined.

The good news is that I have a fix for the problem!

It seems that this event is never removed and is triggering setMountState:

initialImage.addEventListener('load', this.setMountState);

If I modify the componentWillUnmount:

    componentWillUnmount() {
        var images = ReactDOM.findDOMNode(this.item0).getElementsByTagName('img');
        var initialImage = images && images[this.props.selectedItem];
        initialImage.removeEventListener('load', this.setMountState);
        this.unbindEvents();
        this.destroyAutoPlay();
    },

The error is gone after this change!

I tried to create a fork that would have a reproducible error. Unfortunately, I could not pin down the exact combination when this occurs. The project where I can reproduce the bug is written in TypeScript and has more “stuff”.

I could make you a PR with the fix. What I would do is extract new function called getInitialImage that could be used in componentWillUnmount and componentDidMount.

This issue is most likely related: https://github.com/leandrowd/react-responsive-carousel/issues/30

What are your thoughts, boss?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
leandrowdcommented, Apr 23, 2017

Hi @ttamminen, thanks for you PR. All your changes are published as 3.1.7 in npm.

0reactions
travelruscommented, Jun 25, 2020

Seems like this issue reproduces again on 3.2.7

I’m not very expirience in this but maybe it does make sense to relapce the line

var itemSize = isHorizontal ? firstItem.clientWidth : firstItem.clientHeight; on var itemSize = firstItem ? isHorizontal ? firstItem.clientWidth : firstItem.clientHeight : 0;

Read more comments on GitHub >

github_iconTop Results From Across the Web

React throwing error on mounting or mounted component may ...
this.handleResive.bind(this) creates a new function, which means window.removeEventListener('resize', this.handleResize.bind(this)) is also ...
Read more >
stretching problem · Issue #5 · quentin-ol/ngx-openlayers
I get the following Error this.map.updateSize is not a function at <COMPONENT_NAME>. My question is, how do i get access to the updateSize...
Read more >
Again errors.. after a clean install - Dugi Guides
There error show that you haven't updated at all and still using the old files. Make sure you have updated correctly. You might...
Read more >
Fix: "There were some problems installing updates ... - YouTube
Fix: "There were some problems installing updates, but we'll try again later" (0x80070643) Error. 109K views 1 year ago. Tech ...
Read more >
Windows client installation package and content update sizes
If client logging is disabled, and there are no new policies or content to download from the management server, the client installation package ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found