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

issue when using window.getComputedStyle in componentDidMount #220

Closed
chrisdrackett opened this issue Nov 11, 2016 · 1 comment
Closed

Comments

@chrisdrackett
Copy link

I have a component similar to the following that renders fine in our app, however in the style guide it raises errors on window.getComputedStyle(this.element).fontSize. I'm not sure exactly what the bug is, but figured it was worth raising.

import React, { Component } from 'react'

export default class Sample extends Component {

  componentDidMount = () => {
    const x = window.getComputedStyle(this.element).fontSize
    console.log(x)
  }

  render() {
    return (
      <div ref={(element) => this.element = element}>
        Test.
      </div>
    )
  }
}
@mittalabhas1
Copy link

Hey @chrisdrackett, I'm facing a similar issue with jquery. I'm using it from the window as window.$ and it says undefined. Could you point me to how you figured this out?

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

2 participants