Anaïs
 · Full-Stack Developer

State Variable is updated even if you don't call the Update. A bug? 🐞

I have found a problem with the State variables (page or local state variables) when you use one of type List, and the popup. What happens? The List variable is updated even if you don't call the Update Component State or Update Page State action.⚠

See example in this video attached to the post ⬇

Local State Issue .mp4
3.42MB
  • In the first case, I confirm the selection and it returns the selected items. Correct. ✅

  • In the second case, I select new items, but I do NOT confirm the selection, I exit the popup, and yet the List variable has been updated. This is unexpected behavior. ❌ It occurs only with the List type variable. The other var: brand, String type, was not updated.

I do not know if anyone else has experienced the same thing. 🤔

Describing more about what we see in the video. For example, I have this page and component.

Page:

  • This page has declared 2 local variables. These variables should only be updated, with the values selected in the popup, when the popup selection is confirmed. To confirm the selection, the Confirm button must be pressed.

  • When I clic Select, the popup is opened

  • Actions onTap() Select button:

    • This condition works correctly. This means that the variable is not updated from here.

Popup

  • When the Confirm button is pressed, the following actions are performed:

    • I return the selected values only if this button is pressed, otherwise not.

    • FilterOptions corresponds to this data type I created:

I have created a Data Type to return +1 variable in a single variable. It is not a Data Type problem. The problem also occurs when I do not use Data Type.

4
3 replies