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:
- Created 5 years ago
- Comments:14
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Any solution valid for antd@4 ?
Need some solutions for v4