How to get values from input types using this.refs in reactjs?

前端 未结 11 985
耶瑟儿~
耶瑟儿~ 2021-02-03 21:23

Not able to get values of input type using this.refs... how to get that values from input type

   export class BusinessDetailsForm extends Component {
      subm         


        
11条回答
  •  说谎
    说谎 (楼主)
    2021-02-03 21:55

    Avoid Using Ref

    Ref allows you to directly manipulate the DOM, which is against its core concept of Virtual DOM. React discourages us using Refs because of performance issues. But in case of emergency we can use it as below.

        class MyComponent extends React.Component{
           constructor{
    super(props)
    this.inputRef = React.createRef()
    }
    }
    

    and later in our JSX we have to pass is as property named "ref"

    
    

    refer to official documentation for more detail

提交回复
热议问题