event.target[matches] error on form submit in Meteor React project

后端 未结 1 952
借酒劲吻你
借酒劲吻你 2021-01-28 10:17

I am struggling with this bug. Here\'s my code:

It\'s long, so here\'s a short version: I have a form to create an event, I want handleSubmit() to handle error messages

相关标签:
1条回答
  • 2021-01-28 11:02

    So there are two problems with the code:

    1. setState is async. It resolves after the function executes. Workaround: let error = false at the beginning and then set error = true together with setState call.

    2. Empty objects are truthy. Thanks to error variable, we can just change the condition to if(!error). Or do if(error) {return} - this also works.

    Oh, and the error message was from a chrome extension. Sucks that chrome doesn't tell you that an error message came from an extension - at least I don't think it does.

    Best,

    0 讨论(0)
提交回复
热议问题