我有一个带有以下输入元素的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" />
)
}
我想从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
如何使用reactstrap“输入”标签而不是内置的HTML“输入” Dom元素获取价值道具。