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

前端 未结 7 753
小蘑菇
小蘑菇 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:41

    I think I found how to get the ref from React-Bootstrap

    .

     import React, {createRef} from 'react'  
    
        interface definedProps {} 
        interface definedState {
                      myRef: Object //I didn't found the more accurate type
                  } 
        export default class SomeClass extends React.Component {
            state = {
                myRef: React.createRef>() //That's it!
            }
    
        const handleClose = () => {
            console.log('this.state.myRef: ', this.state.myRef); //Here we can take data from Form
            debugger; //todo: remove
        }
    
            render() {
    
                return (
                    
    { /*Here we're connecting the form's ref to State*/} ...
    ) } }

提交回复
热议问题