Using Syntax :
// First method: if Your project concept is only for
// changing/add data without take the previous data
// Set
const [enteredTitle, setEnteredTitle] = useState("");
const [enteredAmount, setEnteredAmount] = useState("");
const [enteredDate, setEnteredDate] = useState("");
// Using
const titleChangeHandler = (event) => {
setEnteredTitle(event.target.value);
};
const amountChangeHandler = (event) => {
setEnteredAmount(event.target.value);
};
const dateChangeHandler = (event) => {
setEnteredDate(event.target.value);
};
// Second method:if Your project concept is for
//changing data & keeping the previous data
// Set
const [userInput, setUserInput] = useState({
enteredTitle: "",
enteredAmount: "",
enteredDate: "",
});
// Using
const titleChangeHandler = (event) => {
setUserInput((prevState) => {
return { ...prevState, enteredTitle: event.target.value };
});
};
const amountChangeHandler = (event) => {
setUserInput((prevState) => {
return { ...prevState, enteredAmount: event.target.value };
});
};
const dateChangeHandler = (event) => {
setUserInput((prevState) => {
return { ...prevState, enteredDate: event.target.value };
});
};