It is a structure present in most navigation actions. It defines a special context, called "navigationContext"
, which is created on the target screen only.
See its structure below:
Attribute | Type | Required | Definition |
---|---|---|---|
value | Any | ✓ | Value to be set at the NavigationContext |
path | String | Path on the NavigationContext structure |
NavigationContext
is not present in openExternalUrl
and openNativeRoute
actionsThe Navigation Context is better used when you want to send information from one screen into another. Next, we have a screen with a button, that when clicked, loads a new view
(which represents another screen). The information contained in the “navigationContext” value
attribute will be saved in the scope of this new screen. This information can be accessed through the expression "@{navigationContext.text}" in the new screen only.
See the example below:
Screen(
child = Button(
text = "Click me!",
onPress = listOf(
Navigate.PushView(
route = Route.Local(
Screen(
child = Text(expressionOf("@{navigationContext.text}"))
)
),
navigationContext = NavigationContext(
value = "textFromNavigation",
path = "text"
)
)
)
)
)
"@{navigationContext.text}"
value as the Text
component valueWas this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.