How is your experience with the OutSystems Community?
18
Views
6
Comments
Solved
Reactive Previous Screen
Question

Hi guys,


I have the following situation, 2 screens A and B (mobile). Screen A has reactive block with a local variable (value 1) that changes value (value 2) before navigating to screen B. 

When on screen B a client action returns to Previous Screen (A) why doesen´t the variable on block of screen A maintain its changed value 2.

This situation happens in reactive block, the same situation on a mobile block keeps the changed value  (2) when returning from screen B to A. 


Thx

PL


2023-09-06 07-26-35
Sudip Pal
Solution

Hey Pedro,

In Reactive Web

When you navigate from Screen A → Screen B:

  • Screen A is typically destroyed
  • Its local variables are reinitialized
  • When you return with Previous Screen, Screen A is recreated from scratch

So, Local variables in Reactive are not preserved across navigation. 

In Mobile Apps

In Mobile:

  • Screens are usually kept in the navigation stack
  • The previous screen instance remains alive in memory
  • Returning restores the existing screen state

So, the local variable still contains the value from memory.


Thanks,

Sudip

2019-01-03 15-52-41
Pedro Lopes

Hi Sudip,

Thx for theh quick response.

Just updated the question, the issue is in a reactive block that is consumed in a mobile page.

If the block is mobile, the value is kept.

2025-04-10 11-25-12
Diogo Reis

Hi Pedro.

If I get it right, your problem is: set a local variable in a block on screen 1, navigate to other screen and, when returning to screen 1 the value is different.

If that is the problem, here is the explanation.

When a block is rendered inside a block, all their local variables only exist when the screen exists. After navigating to another screen, all the variables aren't kepted because all the scope is destroyed.

If you want that the values are kepted between screen navigation, you should reconsider change from local variable to a client variable.

If you have further questions, please let me know.

2023-09-06 07-26-35
Sudip Pal

Hey Pedro

Thanks for the clarification.

In your case, the behavior is related to the lifecycle of the Reactive Block itself, not the mobile screen. So, even inside a Mobile screen, a Reactive Block can be reinitialized.

Thanks 

Sudip

2021-11-19 11-12-44
Rui Mendes

If I understand correctly, you want to be able to navigate between screens. 

I’d handle this by using a single page with two blocks, each containing what you previously had on separate pages. 

You can use a variable on the page to toggle between Block A and Block B, and then just add a button inside each block with an event to update that variable. 

I've attached a quick demo 

TestReact10.oml
2024-10-05 13-30-20
Huy Hoang The

Hi @Pedro Lopes ,

Correct, I faced it in 3 projects ODC. i think it have cache when we use back to previous screen.

So we can ưse redirect to screen (skip previous screen ) and set default values for local var in OnInit()


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.