I want to use a data from a previous screen using expo router and .
Here is what I try:
index.js screen:
import { View, Text } from 'react-native';
import { Link } from 'expo-router';
export default function Page() {
const nbData=10;
return (
<View>
<Link href={{pathname: "./page2", params: { data: nbData }}}>p2</Link>
</View>
);
}
In the page2.js screen I want to use nbData. How to do it ?
I’d like to print nbData (10) in page2.js screen:
import { View, Text } from 'react-native';
import { Link } from 'expo-router';
export default function Page() {
return (
<View>
<Text> {nbData /*from index.js*/} </Text>
</View>
);
}