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
Hey Pedro,
In Reactive Web
When you navigate from Screen A → Screen B:
So, Local variables in Reactive are not preserved across navigation.
In Mobile Apps
In Mobile:
So, the local variable still contains the value from memory.
Thanks,
Sudip
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.
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.
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
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
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()