Cannot destructure property .... as undefined

Viewed 3709

the page explodes and in the console I have these errors:

How can I solve this problem, be able to view the form to enter the email;

The page is blank and these are the errors: enter image description here

I solved this problem, it now functions like the photo attached: enter image description here

1 Answers

It is probably because the value of sentEmailStatus it's undefined when the component renders, during the first rendering.

If you want avoid this behaviour, you can change your destructuring:

  const { loading: loadingStatus, error: errorStatus, message: messageStatus } = sentEmailStatus || {};

This is called Short-circuit evaluation. You can check it there Short-circuit evaluation

Related