danielr18 / connected-next-router

A Redux binding for Next.js Router compatible with Next.js.
MIT License
109 stars 30 forks source link

Why not just use Router.push? #33

Closed imgnx closed 4 years ago

imgnx commented 4 years ago

This might be a silly question, but I installed this package from npm without realizing that I can just use import Router from 'next/router' and Router.push('/home') to switch routes from inside an action. So, what is the point of this package?

😂

danielr18 commented 4 years ago

Not a silly question, I created this package when I was migrating an app using react-router-redux to Next.js which relied on the router state being in Redux. The library has actions for navigating in order to keep a similar API to connected-react-router or react-router-redux, see https://github.com/reactjs/react-router-redux#what-if-i-want-to-issue-navigation-events-via-redux-actions, and also to ease migration.

The library just calls Router[method] when you dispatch a navigation action, so if that's the only thing you were using it for, I would agree it's not needed .