Page & Component State
This state is scoped locally to the specific screen (Page) or widget (Component) where it is defined.
Lifecycle
Unlike Global State, these variables do not persist forever. They are tied strictly to the lifecycle of their host.
Page State
Lives: When the user navigates to the Page.
Dies: When the user navigates back (pops the page).
Note: If you push a new page on top, the current page is still "active" in the stack, so its state is preserved until it is removed from the stack.
Component State
Lives: When the Component widget is rendered on the screen (mounted).
Dies: When the Component is removed from the screen (unmounted).
When to Use (Use Cases)
Page State Examples
Search Query: A text variable
searchTextbound to a search bar.Filters: A list definition
selectedcategoriesfor a filter modal.Form Data: Temporary storage for
emailandpasswordbefore the user hits "Submit".
Component State Examples
Internal Toggles: An
isExpandedboolean for an FAQ accordion item.Animation Control: A local variable to track the current animation frame or status.
How to Create
Open the Variables Panel (usually on the right side) for your selected Page or Component.
Click + Add Variable.
Name: Give it a descriptive name (e.g.,
activeTab).Type: Select the Data Type (String, Integer, Boolean, etc.).
Initial Value: Set the default value.
Scoping Rule for Initial Value
[!IMPORTANT] When defining the Initial Value, you cannot access other variables from the same page/component state (because they might not exist yet).
You can only access:
App State (Global variables).
Page/Component Arguments (Parameters passed into this screen).
Updating State
To modify the value of a Page or Component state variable (e.g., updating count when a button is clicked), you must use the Set State action.
Action: Set State Action
Usage: Select the specific variable you want to update and define the new value.
Last updated