react-router-redux

React router + redux navigating back doesn't call componentWillMount

纵饮孤独 提交于 2019-12-05 16:51:23
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 some sort of way to reload data in this case? Should I maybe use another method of preloading data? I see

hide id or query string while passing through react router

眉间皱痕 提交于 2019-12-05 16:44:32
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", If you want to change url to '/invite-members', you can add the Redirect component. And in case you want to save

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

允我心安 提交于 2019-12-05 03:46:54
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 I (at least) have a different store/state for each main route path? I think routes should be some

react-router Redirect vs history.push

断了今生、忘了曾经 提交于 2019-12-04 16:54:15
问题 I was reading react-router-redux examples and I confused, what is the difference beetween: import { Redirect } from 'react-router-dom' ... <Redirect to='/login' /> and import { push } from 'react-router-redux' ... push('/login') 回答1: Redirect Rendering a <Redirect> will navigate to a new location. The new location will override the current location in the history stack, like server-side redirects (HTTP 3xx) do. whereas History push function Pushes a new entry onto the history stack 回答2: The

How to hydrate server-side parameters with React + Redux

我与影子孤独终老i 提交于 2019-12-04 15:33:14
I have a universal React app that is using Redux and React Router. Some of my routes include parameters that, on the client, will trigger an AJAX request to hydrate the data for display. On the server, these requests could be fulfilled synchronously, and rendered on the first request. The problem I'm running into is this: By the time any lifecycle method (e.g. componentWillMount ) is called on a routed component, it's too late to dispatch a Redux action that will be reflected in the first render. Here is a simplified view of my server-side rendering code: routes.js export default getRoutes

Configuring app's basename in react-router

*爱你&永不变心* 提交于 2019-12-04 11:38:30
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 an ENV variable and make it available both to Webpack and to the app itself by injecting window.defs

How to pass actions down to the components in redux

时间秒杀一切 提交于 2019-12-04 10:14:34
I want to fire an action down in my component. This is a presentation component and need not be redux aware. Router implementation is done using react-router-redux. main.js: let store = createStore(rootReducer) const history = syncHistoryWithStore(hashHistory, store) class RenderClass extends Component { render() { return ( <Provider store={store}> <Router history={history}> <Route path="/" component={MainLayout}> <Route name="employees" path="/employees" url="http://localhost:8080/" component={EmployeeTable}></Route> <Route name="personalInformation" path="/personalInformation/:employeeId"

How to provide a history instance to a saga?

☆樱花仙子☆ 提交于 2019-12-04 09:16:33
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="/page2" component={PageTwo}/> </div> </ConnectedRouter> ); } } The saga looks like: import {

How to use react-router-redux routeActions?

谁说胖子不能爱 提交于 2019-12-03 09:59:31
问题 I'm trying to modify the example code of react-router-redux. https://github.com/rackt/react-router-redux/blob/master/examples/basic/components/Home.js this is my Home.js class Home extends Component { onSubmit(props) { this.props.routeActions.push('/foo'); } } I also have a mapDispatchToProps for it. function mapDispatchToProps(dispatch){ return bindActionCreators({ routeActions },dispatch); } When i called onSubmit function, I got an error Uncaught TypeError: this.props.routeActions.push is

onEnter Transitions with React Router and Redux Simple Router Dont Render New Route's Component

拜拜、爱过 提交于 2019-12-03 05:19:35
问题 I have an app using react @0.14, redux @3.05, react-router @1.0.3, and redux-simple-router @2.0.2. I'm trying to configure onEnter transitions for some of my routes based on store state. The transition hooks successfully fire and push new state to my store, which changes the url. However, the actual component that is rendered on the page is the original component handler from the route match, not the new component handler for the new url. Here is what my routes.js file looks like export