react-router-redux

What difference between using `compose` for middleware or list them in `applyMiddleware`

落花浮王杯 提交于 2021-02-08 12:05:05
问题 What the difference between these configureStore functions and where has gone initialState argument? import { createStore, applyMiddleware } from 'redux'; import logger from 'redux-logger'; import thunk from 'redux-thunk'; import rootReducer from '../reducers'; export default function configureStore(initialState){ const store = createStore( rootReducer, initialState, applyMiddleware(thunk, logger) //list of middlewares in arguments ); return store; } export default function configureStore() {

What difference between using `compose` for middleware or list them in `applyMiddleware`

ε祈祈猫儿з 提交于 2021-02-08 12:02:56
问题 What the difference between these configureStore functions and where has gone initialState argument? import { createStore, applyMiddleware } from 'redux'; import logger from 'redux-logger'; import thunk from 'redux-thunk'; import rootReducer from '../reducers'; export default function configureStore(initialState){ const store = createStore( rootReducer, initialState, applyMiddleware(thunk, logger) //list of middlewares in arguments ); return store; } export default function configureStore() {

“Could not find router reducer” error when using connected-react-router

浪尽此生 提交于 2020-08-20 02:04:09
问题 I repeatedly get a Could not find router reducer in state tree, it must be mounted under "router" error when I do a dispatch(push("/")); call. index.tsx const store = configureStore(); ReactDOM.render( <Provider store={store}> <ConnectedRouter history={history}> <Switch> <Route exact path="/" component={HomeScreenContainer} /> <Route exact path="/login" component={LoginScreenContainer} /> </Switch> </ConnectedRouter> </Provider>, document.getElementById('root'), ); configureStore.ts export

react-router scroll to top on every transition

北慕城南 提交于 2020-01-27 03:26:25
问题 I have an issue when navigating into another page, its position will remain like the page before. So it wont scroll to top automatically. I've also tried to use window.scrollTo(0, 0) on onChange router. I've also used scrollBehavior to fix this issue but it didnt work. Any suggestion about this? 回答1: The documentation for React Router v4 contains code samples for scroll restoration. Here is their first code sample, which serves as a site-wide solution for “scroll to the top” when a page is

react-router scroll to top on every transition

冷暖自知 提交于 2020-01-27 03:26:11
问题 I have an issue when navigating into another page, its position will remain like the page before. So it wont scroll to top automatically. I've also tried to use window.scrollTo(0, 0) on onChange router. I've also used scrollBehavior to fix this issue but it didnt work. Any suggestion about this? 回答1: The documentation for React Router v4 contains code samples for scroll restoration. Here is their first code sample, which serves as a site-wide solution for “scroll to the top” when a page is

Map a route parameter to under a Redux store's key

霸气de小男生 提交于 2020-01-07 06:27:07
问题 There is a "location" key in the state object which is used by multiple components as data source. In the URL (very similar to google maps) I have a parameter called "location" which is a coordinate. My goal is to map that value (with some modification) to the state's "location" key. How to do that? UPDATE The only way I could imagine is to create a middleware and react to route actions, extract the parameters from the URL somehow, then dispatch a new action that will be processed by a

Redux Saga stopped by LOCATION_CHANGE too early

折月煮酒 提交于 2020-01-04 06:06:35
问题 So I'm injecting Sagas dynamically when the route loads path: '/home', name: 'home', getComponent(nextState, cb) { require.ensure([], require => { let HomePageReducer = require('./containers/HomePage/reducer').default; let HomePageSagas = require('./containers/HomePage/sagas').default; let HomePage = require('./containers/HomePage').default; injectReducer('home', HomePageReducer); injectSagas(HomePageSagas); cb(null, HomePage); }) }, injectAsyncSagas goes like this: export function

redux-simple-router - perform action based on URL

♀尐吖头ヾ 提交于 2020-01-02 07:05:21
问题 I'm using Redux with redux-simple-router. Here's what I'm trying to do. A user hits a URL like so: http://localhost:3000/#/profile/kSzHKGX Where kSzHKGX is the ID of the profile. This should route to Profile container filled out with the details of the profile with id kSzHKGX . My routes look like this: export default ( <Route path="/" component={App}> ... <Route path="profile" component={Profile} /> ... </Route> ) So hitting the above link would give me Warning: [react-router] Location

redux-simple-router - perform action based on URL

99封情书 提交于 2020-01-02 07:04:06
问题 I'm using Redux with redux-simple-router. Here's what I'm trying to do. A user hits a URL like so: http://localhost:3000/#/profile/kSzHKGX Where kSzHKGX is the ID of the profile. This should route to Profile container filled out with the details of the profile with id kSzHKGX . My routes look like this: export default ( <Route path="/" component={App}> ... <Route path="profile" component={Profile} /> ... </Route> ) So hitting the above link would give me Warning: [react-router] Location