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.

Do not support new way to add refs and use refs for Input and Select component

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.10.0

Environment

react 16.5.2

Reproduction link

https://github.com/thinksource/newrest/blob/master/static/src/js/Manager.js

Steps to reproduce

According to document https://reactjs.org/docs/refs-and-the-dom.html#creating-refs The new way to refs is: this.myRef = React.createRef(); when it rend,should like:

rend(){
<Input  ref={this.myRef}/>
}

But when I want to get the value of Input or Select

I try to: console.log(this.myRef.current.value);

What is expected?

the value of Input or Select

What is actually happening?

this.myRef.current is object like:

t {props: {…}, context: {…}, refs: {…}, updater: {…}, saveSelect: ƒ, …}
context: {}
props: {style: {…}, children: Array(2), prefixCls: "ant-select", showSearch: false, transitionName: "slide-up", …}
rcSelect: t {props: {…}, context: {…}, refs: {…}, updater: {…}, onInputChange: ƒ, …}
refs: {}
renderSelect: ƒ (n)
saveSelect: ƒ (n)
state: null
updater: {isMounted: ƒ, enqueueSetState: ƒ, enqueueReplaceState: ƒ, enqueueForceUpdate: ƒ}
_reactInternalFiber: Na {tag: 2, key: null, type: ƒ, stateNode: t, return: Na, …}
__proto__: v

do not have value props


Does Antd component support the old way string ref and get the value?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14

github_iconTop GitHub Comments

17reactions
yonatanmncommented, May 4, 2020

Any solution valid for antd@4 ?

8reactions
medeiroshudsoncommented, Aug 24, 2020

Need some solutions for v4

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 >
A complete guide to React refs - LogRocket Blog
Learn how to use React refs, and why it's important to use them only when React can't handle a function call through its...
Read more >
Using refs in React functional components (part 1) - useRef + ...
To create a ref in a functional component we use the useRef() hook which returns a ... This is another way React supports...
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.Component<AppProps ...
Read more >
How to Use React Refs - Ross Bulat - Medium
React Refs are a useful feature that act as a means to reference a DOM element or a class component from within a...
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