Not able to get values of input type using this.refs... how to get that values from input type
export class BusinessDetailsForm extends Component {
subm
I think the more idiomatic way is to use state
instead of refs
, although it's a little more code in this case since you only have a single input.
export class BusinessDetailsForm extends Component {
constructor(props) {
super(props);
this.state = { googleInput: '' };
this.defaultValue = 'someValue';
this.handleChange = this.handleChange.bind(this);
this.submitForm = this.submitForm.bind(this);
}
handleChange(e) {
const { field, value } = e.target;
this.setState({ [field]: value });
}
submitForm() {
console.log(this.state.googleInput);
}
render() {
return (
);
}
}
See https://facebook.github.io/react/docs/forms.html#controlled-components.