Connected-react-router: Upgrade to RRv6?

Created on 2 Mar 2020  路  7Comments  路  Source: supasate/connected-react-router

react-router is about to release v6 soon (as of today, v6.0.0-alpha.2 is out). Will connected-react-router be compatible with the new version, or is an upgrade planned soon?

Sorry if I missed any info on this.

Most helpful comment

@supasate Could you maybe release a preview version that's working with v6? I'd like to test it in my project and give feedback 馃檪

All 7 comments

I just started working on it on the dev branch. Now, it passes all unit tests, but I haven't tested it on some sample apps and will do during weekends. Feel free to check it out and let me know if it works.

Note that there is a minor issue on RRv6 on history listening that causes a memory leak warning. I tried to fix it in this PR https://github.com/ReactTraining/react-router/pull/7195.

@supasate Could you maybe release a preview version that's working with v6? I'd like to test it in my project and give feedback 馃檪

Just bumping this issue and echoing the request for a preview version release (if possible)! react-router v6 entered beta stage about a month ago, and I'm looking forward to upgrading to and using the latest versions of these packages.

Hello. I created a temporary solution for react-router 6 navigation from redux-saga (a very simple version of connected-react-router). It includes redux middleware, reducer, one action (push), and BrowserRouter component. You can try it unless the new version of connected-react-router will have been created.
https://gist.github.com/nikakoy131/09cbbaa2563871ff2d2955c7681a3727
It very poor tested, and have @reduxjs/toolkit and typescript as dependency
Usage:
Configure store

// in store.ts
import { createBrowserHistory } from 'history';
import { configureStore } from '@reduxjs/toolkit';
import { routerReducer, routerMiddleware } from './customReduxRouter';
const sagaMiddleWare = createSagaMiddleware();
export const history = createBrowserHistory({ window });
const store = configureStore({
  reducer: {
    router: routerReducer,
  },
  middleware: [sagaMiddleWare, routerMiddleware(history)],
});

sagaMiddleWare.run(rootSaga);

export type AppState = ReturnType<typeof store.getState>;

export default store;

In your index.tsx

import App from './App';
import store, { history } from './redux/store';
import { BrowserRouter } from './redux/customReduxRouter';
ReactDOM.render(
  <Provider store={store}>
    {/* <ConnectedRouter history={history}> */}
    <BrowserRouter history={history}>
      <App />
    </BrowserRouter>
    {/* </ConnectedRouter> */}
  </Provider>,
  document.getElementById('root'),
);

In your saga

import { routerActions } from '../customReduxRouter';
import { put } from 'redux-saga/effects';

function* someSuperSaga() {
 // your logic ...
 yield put(routerActions.push('/'));
}

See https://github.com/supasate/connected-react-router/pull/438 for a temporary fix. I am not sure it is the correct/performant way to support the new React Router v6-beta.0, but it works.

Hello @supasate,
I was wondering about the status on this issue. Would be awesome to get some updates!
Also thanks for the great work! 馃憤

Ping ping. @supasate any chance for an alpha or beta version with support for react-router@v6^?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tonoslav picture tonoslav  路  4Comments

bmueller-sykes picture bmueller-sykes  路  4Comments

pachuka picture pachuka  路  4Comments

zry754331875 picture zry754331875  路  3Comments

AdrienLemaire picture AdrienLemaire  路  5Comments