I'm new to react and learn it through a tutorial about ethereum. Here is how the form with multiple fields is created:
const Input = ({ placeholder, name, type, value, handleChange }) => (
<input placeholder={placeholder}
type={type}
step="0.0001"
value={value}
onChange={(e) => handleChange(e, name)}
className="noTailwind"
/>
);
<Input placeholder="address to" name="addressTo" type="text" handleChange={handleChange} />
<Input placeholder="Amount (ETH)" name="amount" type="text" handleChange={handleChange} />
<Input placeholder="Keyword (Gif)" name="keyword" type="text" handleChange={handleChange} />
<Input placeholder="Enter message" name="message" type="text" handleChange={handleChange} />
Then handleChange is called in TransactionContext.jsx:
const [formData, setformData] = useState({ addressTo: "", amount: "", keyword: "", message: "" });
const handleChange = (e, name) => {
setformData((prevState) => ({ ...prevState, [name]: e.target.value }));
};
When I type in the form I see the first letter (keypress) appears in the console, but nothing is shown in the form and other key presses are not registered.
Please help me out with solving this error