Skip to content
Advertisement

form.js:24 Uncaught TypeError: Cannot destructure property ‘name’ of ‘e.target’ as it is undefined

im getting some error saying cant destructure the property ‘name’ of e.target undefined I will be grateful for any help. unable to assign any value in the input field. I need to sign up as a client, but when I enter the value they can’t assign, what can i do ?

JavaScript

i also writen a code for email and password separatly this is my email code:

JavaScript

this is my password code:

JavaScript

Advertisement

Answer

There’s a lot here, so I’m taking a quick first pass.

Let’s look at your EmailInput component. It takes onChange as a prop. When the internal TextField component experiences a "change" event, it calls the internal function EmailInput > handleChange; that in turn calls whatever function was passed in the onChange prop to the EmailInput component.

So in EmailInput, this line is calling whatever function was passed to onChange as a prop:

JavaScript

So the first argument is fieldname, which is probably a String. The second argument is an Object with properties value and error. What function is being called? Let’s look at your Form component:

JavaScript

So you see, handleChange is the actual function that we call inside EmailComponent when we call onChange. Right now, handleChange only takes one argument, “e“, though as you can see above we are passing it two. Furthermore, it seems to expect e to be an Object with a target property, but it is actually a String, fieldname.

Therefore, the handleChange function inside the Form component should look something like this:

JavaScript

You might run into a problem because I don’t see you providing the fieldname prop to EmailInput; maybe add something like this here:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement