Hi all, using @ionic/vue
for a project. Need routes that point to specific displays of an object. Got that part working:
In routes:
[{
path: '/',
component: () => import('@/App.vue'),
children: [
{
path: 'object/:objectId',
component: () => import('@/views/SingleObject.vue'),
props: ({params}) => ({ objectId: Number(params.objectId) })
},
...
Problem arises when I navigate away from this page, and then navigate to the same route but with a different ID. Instead of updating the component’s props with the new ID, or tearing down the first instance of the component and creating a new one with the new props, Ionic appears to just serve up the original component. I only see the rendering of the new object if I perform a full page refresh.
On the component:
props: {
objectId: { required: true, type: Number }
}
And a watcher in setup()
:
watch(
() => props.objectId,
(a, b) => {
// reached only once
debugger
},
{ immediate: true }
)
I was wondering if this might have something to do with IonPage, since I know Ionic has big trouble with any view component that isn’t wrapped in that component; maybe both routes resolve to the same instance of IonPage and that’s why the router doesn’t recalculate the prop from the route?
I doubt that’s the case though because I tried this:
<IonPage :key="router.currentRoute.value.params.flashcardId">
Idea being to access the route directly and force Ionic to generate a new instance for each path. But this has no effect.
As expected, both beforeRouteEnter()
and ionViewDidEnter()
hooks are firing.
Does anyone know what’s going on here?