Skip to content

[BUG] useGetToPath is not working #7159

@Bugrabugra

Description

@Bugrabugra

Describe the bug

useGetToPath always returns undefined. Documentation is also wrong.

https://refine.dev/docs/routing/hooks/use-get-to-path/#usage

At docs >
getToPath({
resource: This doesn't accept string like the docs says so, it should be an object like {name: "blog_posts"}

Steps To Reproduce

  1. npm create refine-app@latest refine-test
  2. ✔ What would you like to name your project?: · refine-test
    ✔ Choose your backend service to connect: · data-provider-custom-json-rest (REST)
    ✔ Do you want to use a UI Framework?: · antd
    ✔ Do you want to add example pages?: · yes
    ✔ Do you need any Authentication logic?: · none
  3. open src/pages/categories/list.tsx
  4. add a button before Table comp.
Image
  1. define hooks.
  const getToPath = useGetToPath()
  const go = useGo()
  1. define the handler to be called upon clicking the button
  const clickHandler = () => {
    const path = getToPath({
      resource: {
        name: "blog_posts"
      },
      action: "edit",
      meta: {
        id: "1"
      }
    })

    console.log(path)

    go({
      to: path
    })
  }

path is always undefined, there is no way I could get a meaningful value.

Expected behavior

getToPath should return a string to be passed to go({to: }) key.

Packages

System:

  • OS: macOS 15.7.2
  • CPU: (8) arm64 Apple M2

Binaries:

  • Node: 22.12.0 - /Users/bugraotken/.nvm/versions/node/v22.12.0/bin/node
  • Yarn: Not Found
  • npm: 10.9.0 - /Users/bugraotken/.nvm/versions/node/v22.12.0/bin/npm

Browsers:

  • Chrome: 143.0.7499.42
  • Firefox: 145.0.2
  • Safari: 26.1

Refine Packages:

  • @refinedev/antd: 6.0.3
  • @refinedev/cli: 2.16.50
  • @refinedev/core: 5.0.6
  • @refinedev/devtools: 2.0.3
  • @refinedev/kbar: 2.0.1
  • @refinedev/react-router: 2.0.3
  • @refinedev/simple-rest: 6.0.1

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions