Skip to content

Cannot read properties of null (reading 'getBoundingClientRect') #75

@leekung

Description

@leekung

I got this error on production build website
Sentry stack trace show me that the error is from this package

Screenshot 2023-08-31 at 22 23 48

I don't know why element is null, maybe we have to check

function isVisible(el: Element, view: Element | null): boolean {
  if (!el) return false; //<-- maybe we add this to prevent error
  const elRect = el.getBoundingClientRect();
  if (!view) return elRect.top >= 0 && elRect.bottom <= window.innerHeight;
  const viewRect = view.getBoundingClientRect();
  return elRect.top >= viewRect.top && elRect.bottom <= viewRect.bottom;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions