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

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

    This worked for me, using https://reactjs.org/docs/refs-and-the-dom.html

     constructor(props) {
            super(props);
            this.email = React.createRef();
        }
    
    submit() {
            var email = this.email.current.value;
            console.log(email);
    }
    render() {
       return (
                
    ); }

提交回复
热议问题