So I am still relatively new to React. I want to get data from three form inputs (and eventually post that to database). I have been using the internet to help, but I figured would try my luck here. Right here I am trying to just log out what the user texts in the inputs.
import React from 'react';
export default class AddForm extends React.Component {
constructor(props) {
super(props);
}
handlePlace(e) {
e.preventDefault();
const text = this.place.value.trim();
console.log(text);
}
handleDate(e) {
const text = this.date.value
console.log(text);
}
handleNotes(e) {
const text = this.notes.value
console.log(text);
}
render() {
return(
<form className="form">
<h4>Add a Memory</h4><br></br>
<p className="add-info">Keep track of all the fun and amazing places you
have been.</p>
<input type="text" name="place" placeholder="place" ref={input =>
this.place = input}></input><br></br>
<input placeholder="time" ref={input => this.date = input}></input><br>
</br>
<input className="notes" placeholder="notes" ref={input => this.notes =
input}></input><br></br>
<button className="save" type="button" onClick=
{this.handleSave}>Save</button>
</form>
);
}
handleSave() {
console.log(this.handlePlace)
console.log(this.handleDate)
console.log(this.handleNotes)
}
}