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.

Add support for React 16.3 createRef type of ref

See original GitHub issue

Using connectDragSource with an element that is using the new createRef API (introduced in React 16.3.0) instead of callback refs causes the app to crash with the error: TypeError: previousRef is not a function.

https://github.com/facebook/react/pull/12162

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:41
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
im-martijncommented, Jul 30, 2018

Same issue. Should I revert to using the old callback ref, or is there a way to work around this?

6reactions
arshmakkercommented, Nov 2, 2018

I was able to use a workaround as suggested by encapsulating the ref div inside another blank div. example:


 <div>
        <div
          style={{
            position: "relative",
            borderStyle: "dashed",
            width: 300,
            height: 200,
            position: "relative"
          }}
          ref={this.myRef}
        />
      </div>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refs and the DOM - React
Refs are created using React.createRef() and attached to React elements via the ref attribute. Refs are commonly assigned to an instance property when...
Read more >
Introduction to Refs in React 16.3 | by Sean Groff | Medium
In your class constructor method create a class property and assign React.createRef() to it. Add Ref to DOM Element. Tell React to associate...
Read more >
How to use refs in React with Typescript - Stack Overflow
If you're using React 16.3+, the suggested way to create refs is using React.createRef() . class TestApp extends React.
Read more >
How to use React createRef - LogRocket Blog
React provides a feature known as refs that allow for DOM access from components. You simply attach a ref to an element in...
Read more >
What is significance of refs in ReactJS ? - GeeksforGeeks
Create a ref variable using React.createRef(). It was introduced in React 16.3.I version. · Attach ref variable to the React element by using...
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