xxxxxxxxxx
import React, { useRef } from "react";
const TaskFrom = (props) => {
const taskInputRef = useRef("");
const submitHnadler = (e) => {
e.preventDefault();
const enteredValue = taskInputRef.current.value; //by using .current.value we are getting the current Input given by the user and we are incorporating the chnages in input or in new input by useRef.
console,log(enteredValue);//user input
};
return (
<form onSubmit={submitHnadler}>
<label htmlFor="taskInputField">Enter Your Task:</label>
<input type="text" id="taskInputField" ref={taskInputRef} />
{/* using ref on input we are letting know that which input we are trying to get */}
<button>Send Task</button>
<p>{enteredValue}</p>
</form>
);
};
export default TaskFrom;