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

前端 未结 11 1317
耶瑟儿~
耶瑟儿~ 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:38

    In case any one is wondering how to implement ref with hooks :

    // Import
    import React, { useRef } from 'react';
    
    
    const Component = () => {
        // Create Refs
        const exemploInput = useRef();
    
        const handleSubmit = (e) => {
            e.preventDefault();
       
             const inputTest = exampleInput.current.value;
    
         }
    
        return(
            
    }

提交回复
热议问题