react-router-redux

React / redux how to maintain scroll positoin between routes

一笑奈何 提交于 2019-12-13 12:40:57
问题 Working from the redux real-word example code base here I noticed that when I scroll down a large list of repositories, that when I then visit a user page and immediately go back that my scroll position in the repositories list is maintained. However, after I removed the redux DevTools from the Root container I then noticed that my scroll position was no longer maintained. I'm trying to build a similar react/redux web app where it's important to maintain scroll position. Can anyone tell me

How to access the redux store within the redux form

Deadly 提交于 2019-12-11 03:28:10
问题 I'm a newbie to the react-redux world, please correct me if I'm missing something: Basically I'm trying to access the hostname via redux store and use it inside the form. As of now I'm just using the hostname reference window.location within the redux form but I would like to access the hostname via the redux store/ via any other better approach so I can keep the function pure? Thoughts? Thanks Edit: import React from 'react' import { Field, reduxForm } from 'redux-form' const SimpleForm =

How to configure a basename in React Router 3.x

半城伤御伤魂 提交于 2019-12-11 01:14:20
问题 I have an app running at a nested url as opposed to the root. Lets say example.com/app . I read here that in react router 2.x you could configure basenames. How can this be done in react router 3.x? FYI I am also using the react-router-redux package. 回答1: This functionality does not exist in React Router anymore. I went through a similar problem and found this fix. Step 1: Install History (3.0.0) npm install --save history@3.0.0 Step 2: Import { useBasename } from history in your router file

React Router Redux ConnectedRouter Not Updating With Route Change

夙愿已清 提交于 2019-12-10 18:22:59
问题 I'm running into an issue where ConnectedRouter is not updating history on route change. On route change store gets updated history and Router (ConnectedRouter's child) gets updated history but ConnectedRouter's history stays same. The app doesn't render new component but the browser's url changes. index import React from 'react' import ReactDOM from 'react-dom' import { Provider } from 'react-redux' import { ConnectedRouter } from 'react-router-redux' import AppContainer from './containers

React Router or Link Not working

别来无恙 提交于 2019-12-10 17:59:51
问题 I am using react-router-dom in a redux app. This is my initial setup in index.js: ReactDOM.render( <Provider store={store}> <BrowserRouter> <App /> </BrowserRouter> </Provider> , document.getElementById('root')); Then in my App.js I have: render() { return ( <div className="App"> <Route exact path="/" render={ () => { return ( <div> { this.props.categories.map((category)=>{ console.log('category', category) return ( <Link key={category.name} to="/category" >{category.name}</Link> ) }) } </div

React router + redux navigating back doesn't call componentWillMount

北城以北 提交于 2019-12-10 09:24:53
问题 Currently I pre-load data from api in container component's lifecycle method componentWillMount: componentWillMount() { const { dept, course } = this.props.routeParams; this.props.fetchTimetable(dept, course); } It is called when user navigates to route /:dept/:course , and it works fine, until you navigate from let's say: /mif/31 to /mif/33 and then press back button. The component is not actually reinitialized, so the lifecycle method is not called, and the data isn't reloaded. Is there

hide id or query string while passing through react router

送分小仙女□ 提交于 2019-12-07 08:47:41
问题 i am having route where i pass id,but i dont want to show id in url, `<Route path={`${match.url}invite-members/:groupID`} exact component={InviteMembers} />` this gets converted in url https://local..../invite-members/5, but instead of that i want https://local..../invite-members, but the functionality should remain the same as in i get id in invite-members through this.props.match.params.groupID should be as it is,please help using react router "react-router-dom": "^4.2.2", 回答1: If you want

React + Redux + Router - should I use one state/store for all pages/components?

不羁岁月 提交于 2019-12-06 23:03:06
问题 I am using React + Redux, and after reading about react-router-redux and redux-router, and after reading Dan Abramov's answer, I decided to use "vanilla" react-router (I don't care about time travel etc. at this point). The only open question left is how to handle state across different routes. Each route sub-tree can be a different and independent section in my application (especially when it become bigger). Is it still a good practice to have one store to handle all routes/ pages? Shouldn't

Configuring app's basename in react-router

回眸只為那壹抹淺笑 提交于 2019-12-06 08:33:27
问题 I'm struggling a bit with react-router 2.x configuration, specifically app basename. I've an application which may have different base root throughout its lifecycle. For instance: / in development /users in production /account in production after migration The basename comes into play in several places: static asset compilation in Webpack react-router main configuration specifying redirect routes in redux actions providing something like redirectUrl to API calls My current solution is to have

How to provide a history instance to a saga?

本小妞迷上赌 提交于 2019-12-06 02:51:01
问题 I would like to redirect to a new page after successful login. The routes (V4) are used like this: import { browserHistory } from '....browser_history_signleton'; ... class App extends Component { render() { const { authentication: { isSignedIn } } = this.props; return ( <ConnectedRouter history={browserHistory}> <div> <Header/> <Route exact path="/" component={Home}/> <PrivateRoute isAuthorized={isSignedIn} path="/page1" component={PageOne}/> <PrivateRoute isAuthorized={isSignedIn} path="