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.

I’m not sure if this is related to #4 but it seems React has a problem accessing refs when using a Gateway (i think this occurs on unmount - no error appears until after I’ve loaded then unloaded the view which adds the modal). Here’s my code:

https://gist.github.com/MarkMurphy/781e49b0d5a1e6b8218d

This component is based on the react bootstrap modal example found here: https://github.com/facebook/react/blob/master/examples/jquery-bootstrap/js/app.js

The specific error message is:

Uncaught TypeError: Cannot read property 'refs' of null

Full stacktrace is here

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jamiebuildscommented, Jan 29, 2016

I don’t know that this is a fixable one without a change in React as Gateway messes with the owner.

A work around is to use a wrapper component:

class Child extends React.Component {
  componentDidMount() {
    // `this.refs.foo` exists
  }
  render() {
    return <div ref="foo"/>;
  }
}

class Parent extends React.Component {
  render() {
    return (
      <Gateway>
        <Child/>
      </Gateway>
    );
  }
}

Maybe this is something that react-gateway can just do.

0reactions
chardskarthcommented, Apr 19, 2018

Hi, any updates on this? I get null even when using ref callback.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React ref.current is null - Stack Overflow
I'm working on an agenda/calendar app with a variable time range. To display a line for the current time and show blocks for...
Read more >
Ref returns undefined or null in React [Solved] | bobbyhadz
A React `ref` most commonly returns `undefined` or `null` when we try to access its `current` property before its corresponding DOM element is...
Read more >
Refs are set to null instead of undefined when components ...
As a workaround, you can do a loose comparison (pretty common for null): ref == null -> true for undefined and null ......
Read more >
The Beginners Guide to Template Refs - LearnVue
The ref has a default value of null and will actually be the value of the input once our component is mounted.
Read more >
Template Refs - Vue.js
Note that you can only access the ref after the component is mounted. If you try to access $refs.input input in a template...
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