Open tonybrbtravel opened 3 years ago
@tonybrbtravel There is no point on adding these kind of issues here about push. It does not work, and never worked and probably never will. There are hundreds of complains about the same thing all the way back to 2017.
Is quite sad that all of these libraries that do amazing, awesome things, and cannot do the most basic functionality of the internet... redirecting from one url to another. It's quite impressive... or sad.
@tonybrbtravel There is no point on adding these kind of issues here about push. It does not work, and never worked and probably never will. There are hundreds of complains about the same thing all the way back to 2017.
Is quite sad that all of these libraries that do amazing, awesome things, and cannot do the most basic functionality of the internet... redirecting from one url to another. It's quite impressive... or sad.
eh…but why it doesnt work and how to solve it
@Narven @lightyisu This works. You just have to make sure that you do not create your middleware and pass in the history api before calling createRootReducer
function. If you try to create your middleware with routerMiddleware(history)
too early , history
will be passed in as undefined
. Follow the README.md as it explains the exact execution order.
@Narven @lightyisu This works. You just have to make sure that you do not create your middleware and pass in the history api before calling
createRootReducer
function. If you try to create your middleware withrouterMiddleware(history)
too early ,history
will be passed in asundefined
. Follow the README.md as it explains the exact execution order.
Thank u so much for ur help,I will try it😘
After many hours, I have this working.
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit';
import { createBrowserHistory } from 'history'
import createSagaMiddleware from "redux-saga";
import { routerMiddleware } from 'connected-react-router'
import { applyMiddleware, compose } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage' // defaults to localStorage for web
import createRootReducer from './reducers'
import rootSaga from './saga'
export const history = createBrowserHistory();
const persistConfig = {
key: 'root',
storage,
}
const rootReducer = createRootReducer(history);
const persistedReducer = persistReducer(persistConfig, rootReducer)
let sagaMiddleware = createSagaMiddleware();
const middleware = [...getDefaultMiddleware({ thunk: false }), sagaMiddleware, routerMiddleware(history)];
export default configureStore({
reducer: persistedReducer,
middleware
});
sagaMiddleware.run(rootSaga);
import React from 'react';
import ReactDOM from 'react-dom';
import { PersistGate } from 'redux-persist/integration/react'
import { persistStore, persistReducer } from 'redux-persist'
import { ConnectedRouter } from 'connected-react-router'
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";
import './index.css';
import App from './App';
import store, {history} from './app/store';
import { Provider } from 'react-redux';
import * as serviceWorker from './serviceWorker';
let persistor = persistStore(store)
ReactDOM.render(
<React.StrictMode>
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<ConnectedRouter history={history}>
<App />
</ConnectedRouter>
</PersistGate>
</Provider>
</React.StrictMode>,
document.getElementById('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
import React from 'react'
import { Route, Switch } from 'react-router-dom'
import {SignUp} from '../features/sign-up/Signup'
import {SocialSignUp} from '../features/social-sign-up/SocialSignUp'
import {Dashboard} from '../features/dashboard/Dashboard'
import TermsAndConditions from '../features/t-and-c/Terms.js'
const routes = (
<Switch>
<Route exact path="/" component={Dashboard} />
<Route exact path="/email-signup" component={SignUp} />
<Route exact path="/social-signup" component={SocialSignUp} />
<Route exact path="/terms-and-conditions" component={TermsAndConditions} />
</Switch>
)
export default routes
@Narven We've been using the lib in a production app for over 2 years, I can tell you that push definitely works!
The app is wired up such that: -> user lands on Sign-up page -> call is made to action, picked up by the sign-up saga. -> The push is never made.
I'm sure I've wired something up incorrectly, but have spent a day looking at it.
Your help is appreciated.
index.js
app/store.js
App.js
routes.js
Singup.js