I have a react component with the following input element:
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.
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.
Use innerRef instead of ref with your Input component.
https://reactstrap.github.io/components/form/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With