Cannot destructure property .... as undefined
Asked Answered
F

1

8

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

Fuchsin answered 3/2, 2022 at 19:1 Comment(0)
K
9

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

Karakalpak answered 3/2, 2022 at 19:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.