[英]React ref using reactstrap Input Module doesn't have Value prop
I have a react component with the following input element: 我有一个带有以下输入元素的react组件:
import React, {
Component
} from 'react';
import {Input } from 'reactstrap';
constructor(props) {
super(props)
this.test = React.createRef();
}
render() {
console.log(this.test.current)
return (
<Input ref={this.test} defaultValue = "This is the default" />
)
}
I want to grab the value Prop from the ref {this.test} however, when I console log I receive the following output. 我想从ref {this.test}获取值Prop,但是,当我控制台日志时,我收到以下输出。
Input {props: {…}, context: {…}, refs: {…}, updater: {…}, getRef: ƒ, …}
context: {}
focus: ƒ ()
getRef: ƒ ()
props: {defaultValue: "This is the default", onChange: ƒ, type: "text"}
refs: {}
state: null
updater: {isMounted: ƒ, enqueueSetState: ƒ, enqueueReplaceState: ƒ, enqueueForceUpdate: ƒ}
_reactInternalFiber: FiberNode {tag: 1, key: null, elementType: ƒ, type: ƒ, stateNode: Input, …}
_reactInternalInstance: {_processChildContext: ƒ}
isMounted: (...)
replaceState: (...)
__proto__: Component
How do i get a value prop using reactstrap "Input" tag instead of the built in HTML "input" Dom element. 我如何使用reactstrap“ Input”标签而不是内置的HTML“ input” Dom元素来获取价值道具。
Use innerRef instead of ref with your Input component. 在输入组件中使用innerRef而不是ref。
https://reactstrap.github.io/components/form/ https://reactstrap.github.io/components/form/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.