-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
TypeError: Cannot read property 'offset' of undefined #830
Comments
I am also having this issue on react@16 (probably related to the scrollbar repositioning when column count decreases. not sure if this is still the case on react@15). I'm temporarily using error-guarding (componentDidCatch) feature to prevent the whole SPA from breaking. |
I believe this should be fixed by PR #820 which was just merged and will be released with 9.11 in a few moments |
We are bumping into what looks like this issue on 9.18.5 I'm not sure if the cause is going to turn out to be the same or not — me and @LawrenceHunt are currently doing some more detailed investigation and will update here. Hopefully we'll have some more conclusive info shortly! Not sure if this is the best place for this, or if we should open a new issue |
Is there a way to figure out which line of code is causing the error? There are several |
It turns out we reimplemented this bug all by ourselves in a wrapping component and passed I'd be very happy to PR a defence + warning to cover that scenario if that's something you think would be good or helpful. |
gonna defer to @bvaughn for the final decision but a warning covering the use case that someone doesn't pass a number to a prop expecting a number might be overkill. i imagine someone encountering the issue will find this discussion and be able to solve it themselves |
Actually, on second thought, a PR (+ test case 😁) to cancel the action if a falsey value is provided, rather than throwing an exception and breaking down, and then manually log an error is probably a better UX. I'd say open the PR and we can have a discussion about it there! |
thanks for pointing to the problem |
(This may have been fixed with the PR #820: passing -1 as the value for
scrollToColumn
&scrollToRow
prevents the exception. Leaving it here for reference only.)I am also seeing the exception reported in #297. It happens when I drag-resize the container enclosing a MultiGrid (which in turn resizes the MultiGrid). Here is some more detail (I am using [email protected]).
It all seems to start with this stack:
The code executing in the top frame is:
index
is the input parameter ofgetSizeAndPositionOfCell(index)
, and it gets here all the way from_getCalculatedScrollLeft()
in frame [3], where it is calledtargetIndex
and is calculated by:This expression evaluates to
NaN
. It isNaN
becausescrollToColumn
isNaN
, which in turn is so because I do not pass it in as a prop to the Grid. If I do pass it in with, say,scrollToColumn={ 0 }
, the exception disappears. However, if I do this and try to drag the Grid's scroll bar with the mouse, the Grid is continuously reset to position 0, which is no good. I need thescrollToColumn
prop to stay undefined, but if I do that I get the error.The actual exception is triggered when the
NaN
value returned above propagates into a variable calleddatum
used at:The offending line is:
Since
datum
isNaN
... boom.All this also applies to
scrollToRow
, i.e., it must be defined to avoid the exception.I haven't investigated why the exception doesn't occur in the demo at https://bvaughn.github.io/react-virtualized/#/components/Grid even when
scrollToColumn
is not defined. It may have to do with the fact that I am using MultiGrid. The MultiGrid demo doesn't accept undefined values for these props.The text was updated successfully, but these errors were encountered: