Skip to content
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

Uncaught TypeError: this.refs.el.getBoundingClientRect is not a function #9

Open
craig1123 opened this issue Nov 15, 2016 · 7 comments

Comments

@craig1123
Copy link

This error comes from line 145:
getBoundingClientRect() { return this.refs.el.getBoundingClientRect(); }

@masylum
Copy link

masylum commented Nov 21, 2016

I'm also getting the same error. When you initialize the component update gets called and then it bubbles down to getBoundingClientRect. Since the component has not rendered yet it does not have the references in place yet.

@masylum
Copy link

masylum commented Nov 22, 2016

the problem is that the this.refs.el was pointing to a React element instead of a DOM node.
I fixed this wrapping the child on a <div>:

<Sticky debug>
  <div>
    <YearlyCalendar dateTree={{}} />
  </div>
</Sticky>

@soenkekluth
Copy link
Owner

@craig1123 @masylum version 2.1.4 was just published. the problem should be solved. if you update be shure to test if everything else works - and it should better ;)

@dagatsoin
Copy link

dagatsoin commented Jan 21, 2017

I use @2.1.5 with [email protected] and have also this error:

TypeError: this.refs.el.getBoundingClientRect is not a function
    at ReactStickyState.getBoundingClientRect (react-sticky-state.js:154)
    at ReactStickyState.getBounds (react-sticky-state.js:159)
    at ReactStickyState.updateBounds (react-sticky-state.js:251)
    at ReactStickyState.update (react-sticky-state.js:408)
    at ReactStickyState.eval (react-sticky-state.js:533)
    at CallbackQueue.notifyAll (CallbackQueue.js:76)
    at ReactUpdatesFlushTransaction.close (ReactUpdates.js:59)
    at ReactUpdatesFlushTransaction.closeAll (Transaction.js:206)
    at ReactUpdatesFlushTransaction.perform (Transaction.js:153)
    at ReactUpdatesFlushTransaction.perform (ReactUpdates.js:89)

My component:

import React from 'react';
import injectSheet from 'react-jss';

import style from '../theme/splitView';

import Section from '../4-layouts/Section';
import View from '../0-atoms/View';
import Sticky from 'react-sticky-state';

const SplitView = ({sheet:{classes}, renderTop, renderMiddle, renderBottom}) =>
  <View className={classes.wzSplitView}>
    <Section className="top">{renderTop()}</Section>
    <Sticky>
      <View className="handleBar">{renderMiddle()}</View>
    </Sticky>
    <Section className="bottom" secondary>{renderBottom()}</Section>
  </View>;

export default injectSheet(style)(SplitView);

Wrapping in a div also fixes this. But is it an excepted behavior?

<Sticky>
  <div>      
    <View className="handleBar">{renderMiddle()}</View>
  </div
</Sticky>

@hoschi
Copy link

hoschi commented Jul 10, 2017

I have the same error :(
Even with very simple content <Sticky>foo</Sticky>. As @dagatsoin said, wrapping it in a div 'fixes' it.

@stevengrimaldo
Copy link

Am I to assume since this was posted on Nov 15, 2016 it will not be fixed, since it's been about 3 years?

@bbu23
Copy link

bbu23 commented Apr 14, 2021

the problem is that the this.refs.el was pointing to a React element instead of a DOM node.
I fixed this wrapping the child on a <div>:

<Sticky debug>
  <div>
    <YearlyCalendar dateTree={{}} />
  </div>
</Sticky>

Thank you for saving the life of a php developer who's working on a ReactJs project. Bless your soul!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants