Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which useRouter? #4362

Closed
chris-hailstorm opened this issue Jul 22, 2024 · 1 comment
Closed

Which useRouter? #4362

chris-hailstorm opened this issue Jul 22, 2024 · 1 comment
Labels
kind/bug Something isn't working status/done

Comments

@chris-hailstorm
Copy link

chris-hailstorm commented Jul 22, 2024

What is the problem?

useRouter is availabe from multiple libs. Is there one true source? Or how should we decide among them?

  • import {useRouter} from "next/compat/router"
  • import {useRouter} from "next/navigation"
  • import {useRouter} from "next/compat/router"

These all appear in the https://github.com/blitz-js/blitz repo, and in a new project I generated using blitz new.

Just looking for a pattern, it appears that 100% of the time when router.refresh() is used, the next/navigation source is being used. The opposite isn't true -- sometimes next/navigation is used when there's no router.refresh() happening.

Should we only be using one of these? If yes, should the others be removed? If no, how do we know when to use when?

Paste all your error logs here:

N/A

Paste all relevant code snippets here:

N/A

What are detailed steps to reproduce this?

N/A

Run blitz -v and paste the output here:

Blitz version: 2.0.10 (local)
macOS Sonoma | darwin-arm64 | Node: v18.20.4


 Package manager: npm

  System:
    OS: macOS 14.3.1
    CPU: (11) arm64 Apple M3 Pro
    Memory: 533.45 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.4 - ~/.asdf/installs/nodejs/18.20.4/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/yarn/1.22.19/bin/yarn
    npm: 10.7.0 - ~/.asdf/installs/nodejs/18.20.4/bin/npm
  npmPackages:
    @blitzjs/auth: 2.0.10 => 2.0.10
    @blitzjs/next: 2.0.10 => 2.0.10
    @blitzjs/rpc: 2.0.10 => 2.0.10
    @prisma/client: 5.4.2 => 5.4.2
    blitz: ^2.0.10 => 2.0.10
    next: 14.1.4 => 14.1.4
    prisma: 5.4.2 => 5.4.2
    react: ^18.2.0 => 18.3.1
    react-dom: ^18.2.0 => 18.3.1
    typescript: ^4.8.4 => 4.9.5

Please include below any other applicable logs and screenshots that show your problem:

No response

@siddhsuresh
Copy link
Member

siddhsuresh commented Jul 30, 2024

related #4364 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working status/done
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants