I appreciate this may be basic as I'm new to react, but I'm trying to just very simply log the value of the input whenever it is changed or submitted.
Here is the code:
import React from "react";
const App = () => {
const onNameChange = (nameInput) => {
console.log("name change Fn", nameInput);
};
return (
<>
<form onSubmit={onNameChange(this.value)}>
<input value='the value' type="text" onChange={console.log(this.value)}></input>
</form>
</>
);
}
export default App
- Why can I not click inside the form and change the value?
- How can I log the value of the input whenever clicking inside and changing it?
- How can I log the value of the onput on submit?
Thanks... Here is a stackblitz demo: https://stackblitz.com/edit/react-tvk69a