Route
Nano framework has inbuilt route
that comes from react-navigation.
Reading data from route:
All the methods like onPress
, onLongPress
, onStart
, onResume
, onPause
and onEnd
in framework has access to moduleParams parameter that has all the available modules, you can use route
module from it like below.
For example, below is the code to move to another screen with data being read using route
module in second screen.
const buttonPress = {
component: NANO.BUTTON,
value: 'CLICK ME TO MOVE TO SCREEN B',
onPress: ({ moduleParams }) => {
moduleParams["navigation"].navigate("ScreenB", { "name": "value" })
}
};
const screen = {
name: 'ScreenA',
screen: {
h1: [buttonPress]
}
};
Once the ScreenB is mounted, we can get parameters using route
instance in onStart method which gets called when screen is mounted.
const text2 = {
component: NANO.TEXT,
value: "I AM IN SCREEN B",
};
const screen = {
name: 'ScreenB',
screen: {
h1: [text],
},
onStart: ({moduleParams}) => {
console.log(moduleParams["route"].params["name"])
}
};