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

React-router v6 #305

Open
Asher978 opened this issue Jan 17, 2022 · 9 comments
Open

React-router v6 #305

Asher978 opened this issue Jan 17, 2022 · 9 comments

Comments

@Asher978
Copy link

Hello,

Is this react-router v6 compatible?

@eleventhaus
Copy link

Also wondering if this is v6 compatible

@mjrussell
Copy link
Owner

Hi, unfortunately I'm not actively maintaining this repo any more. Looking at the react router v6 docs, it looks like there are some breaking changes so I wouldn't expect this to work without some modifications.

@r3b311i0n
Copy link

I'm starting a fresh project and tried this and it seems to be working fine (with redux-first-history). What are the breaking changes in react-router v6 which affects redux-auth-wrapper?

import { connectedReduxRedirect } from 'redux-auth-wrapper/history4/redirect';
import { replace } from 'redux-first-history';

import LoadingPage from 'components/LoadingPage';

function redirectUser(state) {
  if (state.global.currentUser.id) {
    return '/test';
  }
  return '/login';
}

export const isAuthenticated = connectedReduxRedirect({
  redirectPath: state => redirectUser(state),
  authenticatedSelector: state => !!state.global.currentUser.id,
  authenticatingSelector: state => !state.global.checkedMeAuth,
  allowRedirectBack: false,
  AuthenticatingComponent: LoadingPage,
  wrapperDisplayName: 'IsAuthenticated',
  redirectAction: replace,
});

@mjrussell
Copy link
Owner

That's good to hear! Do you know what version of history you are getting as a transitive dependency?

@r3b311i0n
Copy link

Sure. It's history 5.3.0.

@mjrussell
Copy link
Owner

Based on #267 have you seen the query param populated properly?

@r3b311i0n
Copy link

Seems to be working fine for me (with redirectPath as a string or a function). But I'm using connectedReduxRedirect with redux-first-history instead of connectedRouterRedirect. I think connected-react-router doesn't work well with history 5 and doesn't support react-router 6.

@alibalouchi95
Copy link

in the react-router-dom official website said:

You'll also want to remove the history dependency from your package.json. The history library is a direct dependency of v6 (not a peer dep), so you won't ever import or use it directly. Instead, you'll use the useNavigate() hook for all navigation (see below).

so are you sure it's compatible with v6?

@pinksynth
Copy link

Just to chime in, in case it's helpful to anyone: My app was upgraded to redux-first-history and has been able to use this lib successfully, but I did have to set allowRedirectBack: false or else I got errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants