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.

this.refs is empty

See original GitHub issue

I get this.refs as Object {} and unable to open()/close() drawer

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
toadumscommented, Jan 6, 2016

If your drawer is in a navigator your need to access it through the navigator’s refs

const drawer = this.refs.navigator && this.refs.navigator.refs.drawer;

And make sure you set the ref on the Navigator as well

render() {
  renderScene() {
    ...
    return <Drawer ref="drawer" />;
  }
  return (
    <Navigator ref="navigator" renderScene={this.renderScene} />;
  )
}

You could also use the call back syntax for setting refs: https://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute

1reaction
rt2zzcommented, Dec 3, 2015

did you set ref="drawer" on your drawer component?

Alternatively you can try using the drawer via context

Read more comments on GitHub >

github_iconTop Results From Across the Web

this.$refs always empty or undefined in Vue component
$refs either always comes back undefined or as an empty object, and I don't know what I'm doing wrong. In a parent component,...
Read more >
[Solved] This.$refs return empty object - Get Help - Vue Forum
I want to get my element like javascript's document.getElementById('elementId'), but it doesn't work. I've done a search and it's say i ...
Read more >
$refs empty in mounted callback when another component is ...
Make another Vue component a parent of your current component and $refs will be undefined. Worked as it should in 2.14 with @nuxt/components...
Read more >
A complete guide to React refs - LogRocket Blog
Learn how to use React refs, and why it's important to use them ... Instead, we use useRef(null) to create refs in functional...
Read more >
[Solved]-Vue.js this.$refs empty due to v-if-Vue.js
... during mounting it cannot work since the $refs.autocomplete is not existing yet but I'm not sure you need it since your v-model...
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