Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG | useRouteParams | navigate back breaks the route param #5160

@ThiloHettmer

Description

@ThiloHettmer

Describe the bug

When I navigate away from a page with useRouteParams and navigating back via the browsers back button the route param looses reactivity somehow.

This does not work

<script setup lang="ts">
const foo = useRouteParams('foo', '', { transform: String })

const { data, status } = await useAsyncData(`some-key:${foo.value}`, () =>
  GqlSomeFetch({
    foo: foo.value,
  }),
)
</script>

<template>
  <UButton to="some-route" label="Some Route" />
</template>

This works:

const route = useRoute()
const foo = computed(() => route.params.foo as string)

Reproduction

WIP

System Info

WIP

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions