使用 reactstrap 输入模块的 React ref 没有 Value prop

React ref using reactstrap Input Module doesn't have Value prop

我有一个带有以下输入元素的 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 "Input" 标签而不是内置的 HTML "input" Dom 元素来获取价值道具。

在您的输入组件中使用 innerRef 而不是 ref。

https://reactstrap.github.io/components/form/