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.

Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null

See original GitHub issue

I can’t seem to get react-sticky to work when attempting to use my own component

              <StickyContainer>
                <Sticky>
                  {({style}) => (<SearchResultsBar style={style} onFilterClick={this.props.handleFilterClick} />)}
                </Sticky>
                ...
              </StickyContainer>

When I attempt the above I get Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null at Sticky.js:61.

var contentClientRect = _this.content.getBoundingClientRect();

If I do the above, but don’t attempt to pass any of my own props, and just return the component by name it works:

              <StickyContainer>
                <Sticky>
                  {SearchResultsBar}
                </Sticky>
                ...
              </StickyContainer>

I’m assuming I’m missing something simple, but I don’t know what it is. The SearchResultsBar is a stateless functional component if that makes a difference. This is using 6.0.1.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
dndcommented, May 10, 2017

@dbarbalato, I actually just got finished trying that, and it appears to work correctly as a class extending Component.

2reactions
pupuducommented, Oct 14, 2019

If it helps anyone, forwarding the rest of the props to a wrapping div seems to fix the problem

<Sticky>
     {({style, isSticky, ...rest}) => (
         <div {...rest}>
             <SearchResultsBar style={style} onFilterClick={this.props.handleFilterClick} />
         </div>
     )}
</Sticky>
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'getBoundingClientRect' of null
I'm trying to create a header with a Sticky effect, but I'm having this error when scrolling the page, sometimes it works and...
Read more >
Cannot read property 'getBoundingClientRect' of null · Issue ...
I am creating a slider it does render the component and the styles however I do get a js error: Uncaught TypeError: Cannot...
Read more >
TypeError: Cannot read property 'getBoundingClientRect' of null
Suspected problems and effort to solve this: Error message: I get the same error message “TypeError: Cannot read property 'getBoundingClientRect' of null” from ......
Read more >
Throwing Cannot read property 'getBoundingClientRect' of ...
The error keeps coming from Sentry from a user using windows xp and chrome v49.0.2623, and several users using windows 10 and Edge...
Read more >
TypeError: Cannot read property 'getBoundingClientRect' of null
Hi, The issue I am experiencing looks similar to (see link below), except I am using the angular 2+ diagrams component. It only...
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