How to get an input value using “refs” in react-bootstrap form?

前端 未结 7 754
小蘑菇
小蘑菇 2021-02-05 04:01

I\'m trying to create a form that appears in modal. So when user input a value, that value is stored in local storage. Here\'s a picture that help\'s you to understand what I me

7条回答
  •  时光说笑
    2021-02-05 04:55

    I have same problem with you, and this is my solution

    const FieldGroup = ({id, label, help, inputRef, ...props}) =>
      
        {label}
        
        {help && {help}}
      
    

    and my form

    this.inputName = input } /> this.inputAuthor = input} />

    then you can get book 's name and author 's name value by:

    this.inputName.value and this.inputAuthor.value
    

提交回复
热议问题