Tell us what’s happening:
The code works for what the test is asking. It renders an ul of each item in the messages array, but for some reason it is not passing the tests.
I’ve changed the submit button to the same text the test says to use and double checked my spelling of the submitMessage method, and I can’t find why it’s not passing.
when you wish to prevent the default action of a certain thing… in your case… in order to prevent the page from refreshing when a form is submitted you would call the preventDefault method on the event object
It doesn’t seem to make a difference in this case.
The challenge doesnt ask for it specifically. However if you want you can use it, just pass it to the function definition like so:
submitMessage(event){
//now you can reference this object if you desire
console.log(event)
}
some other details that might help:
A form submission is when you might want to send some data to a server… its not in the same location as the app (which is with the client). the default action of most browsers is to refresh the page in order to do this. however you have react … maybe you want to intervene… let react handle it instead, maybe not send this data right away/send it at a later time… who knows what you might want to do… but thats what its for. I hope that makes sense.
I think I’m starting to understand. I think this is hard to wrap my head around because I don’t know how it works in a real world application. I feel like once I start actually building something and am able to tinker with things a bit more it will make more sense.