So let's dive into error messages in react application. In the project you worked on thus far, in
the nameChangedHandler, I'll add an error. In the code there where we assigned person, the updated person
here,
we reach out to event target value to get the value the user entered. Here where I assigned a value,
let's say we're not accessing event target which is correct but event input which is incorrect.
Well let's say we made this mistake,
now if you go back to the application on the first look it seems to work,
we toggle a person, it still works but if I start typing we actually get an error,
and in our development workflow, we even get a nice display of the error here in the middle.
Now let's focus on the error message on the right,
always scroll up all the way to the top to see your error message
and there you see cannot read property value of undefined.
You also get a hint at where this occurred in nameChangedHandler
app.js
line 27, and it's displayed even nicer here in the middle,
you get it highlighted event input value.
So this line seems to be incorrect and there is no value property on undefined, now that simply means
the part prior to value,
so this part here, is undefined which is the case because there is no input property on event.
Now you still need to figure out the target is correct on your own
for example by looking into the event documentation that's the you can look into the normal html
input event documentation
but you get a clear clue about what went wrong and where.
Now sometimes error messages are less helpful than this one is, even if the error message itself is cryptic.
Most of the time you should get a helpful line number which allows you to go back into your code and
try to find out what's wrong about this line,
this should be helpful and should allow you to fix the value.
This is how you react on react error messages,
don't get afraid,
don't panic,
oftentimes these error messages are really useful,
you should read them and you should have a look at the line numbers
they point you to.
Now what about logical errors though?
Let's have a look at these in the next lecture.