How get data from material-ui TextField, DropDownMenu components?

后端 未结 10 2018
遥遥无期
遥遥无期 2021-01-31 01:13

I create form, I have several TextField, DropDownMenu material-ui components included, question is how I can collect all data from all TextFields, DropDownMenus in one obj and s

10条回答
  •  轮回少年
    2021-01-31 01:38

    In 2020 for TextField, via functional components:

    const Content = () => {
       ... 
          const textFieldRef = useRef();
    
          const readTextFieldValue = () => {
            console.log(textFieldRef.current.value)
          }
       ...
      
          return(
           ...
           
           ...
          )
    
    }
    

    Note that this isn't complete code.

提交回复
热议问题