Skip to content

useRouter is not available in extension components #17718

@mantis-toboggan-md

Description

@mantis-toboggan-md

Setup

  • Rancher version: 2.14.1 (prime)
  • Rancher UI Extensions: see description
  • Browser type & version: ff

Describe the bug
Extension components using the composition api appear unable to access useRouter() -- it always returns undefined. Composition components are able to use this.$router as expected. This bug is not reproducible when running extensions locally; they must be built and loaded into the dashboard

To Reproduce
This issue was noticed during virtual clusters ui development. I've created a small test extension to reproduce it here: https://github.com/mantis-toboggan-md/simple-extension

The extension adds edit pages for limitRange and resourceQuota resources.

The limitrange page uses the composition api and calls useRouter() to get a url and render it on the page. This results in a console error and no url is rendered.

The resourceQuota edit component uses the options api and calls this.$router to get a url and render it on the page. This works as expected.

Expected Result
Extensions should be able to use useRouter()

Screenshots

Additional context
Possibly related to #10543

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions