The vue-native-router docs provide a good example about how to implement a navigation to switch between screens, which works so far in my little demo app that I'm trying to build to get a grasp about how things work.
The basics that are required to navigate from one screen to another, inside a screen vue template, are so far:
<template>
<view class="o-container">
<button title="ChangeView" :on-press="goToMyNewFancyView" />
</view>
</template>
<script>
export default {
props: {
navigation: {
type: Object
}
},
methods: {
goToMyNewFancyView() {
this.navigation.navigate('MyNewFancyView');
}
}
};
</script>
(I've skipped the main setup of the StackNavigator as this is completely the same as in the docs and not really helpful for this question, see TJ Weems answer).
My aim is now to have a list of components that display a title and a description. By clicking on the component, the screen should be changed to the component's detail view. Thus, I tried to implement the same for my component:
<template>
<view>
<text>This is a component.</text>
<button title="show more" :on-press="show" />
</view>
</template>
<script>
export default {
props: {
navigation: {
type: Object
}
},
methods: {
show() {
this.navigation.navigate('MyShowView');
}
}
};
However, this.navigation is undefined inside the vue component. Somehow I don't understand the connections here and could not find anything relatable that would explain this. I'm also not sure if this is the correct way, or if navigation should happen outside of the component at all.
How would one implement a link from a component that is a teaser for a thing to the actual detail screen?
Dependencies:
"dependencies": {
"expo": "^32.0.0",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz"
},
"devDependencies": {
"@babel/core": "^7.0.0-0",
"babel-preset-expo": "^5.0.0",
"vue-native-core": "0.0.8",
"vue-native-helper": "0.0.10",
"vue-native-router": "0.0.1-alpha.3",
"vue-native-scripts": "0.0.14"
},