I can't read attribute ref
after the form validation. The result is undefined
and I don't understand why.
import React from 'react';
import {Link} from 'react-router-dom';
export default class Home extends React.Component {.
handleSubmit(e){
e.preventDefault();
console.log(e.name.value);
}
render() {
return (
<div>
<form onSubmit={this.handleSubmit}>
<input type='text' ref={ (input) => this.name = input} />
<input type='text' ref={ (input) => this.topic = input} />
<input type='submit'/>
</form>
</div>
)
}
}