Questions tagged [react-router-redux]

A library of bindings to keep react-router and redux in sync (formerly known as redux-simple-router).

A library of bindings to keep react-router and redux in sync (formerly known as redux-simple-router).


Related tags

502 questions
183
votes
23 answers

react-router scroll to top on every transition

I have an issue when navigating into another page, its position will remain like the page before. So it won't 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…
adrian hartanto
  • 1,865
  • 2
  • 8
  • 9
158
votes
17 answers

React-Router External link

Since I'm using react-router to handle my routes in a react app, I'm curious if there is a way to redirect to an external resource. Say someone hits: example.com/privacy-policy I would like it to redirect…
Eric Hodonsky
  • 4,117
  • 3
  • 22
  • 36
103
votes
8 answers

Detect Route Change with react-router

I have to implement some business logic depending on browsing history. What I want to do is something like this: reactRouter.onUrlChange(url => { this.history.push(url); }); Is there any way to receive a callback from react-router when the URL…
83
votes
6 answers

How to sync Redux state and url query params

I have a web page with a search panel. Search panel has several input fields: id, size, ... What I want is when user set search values (for example: id=123 and size=45) and press a search button: searchState in Redux reducer should be updated with…
77
votes
2 answers

How to sync Redux state and url hash tag params

We have a list of lectures and chapters where the user can select and deselect them. The two lists are stored in a redux store. Now we want to keep a representation of selected lecture slugs and chapter slugs in the hash tag of the url and any…
JoKer
  • 1,064
  • 1
  • 8
  • 11
58
votes
7 answers

react-router-dom with TypeScript

I'm trying to use react router with TypeScript. However, I have certain problems using withRouter function. On the last line, I'm getting pretty weird error: Argument of type 'ComponentClass<{}>' is not assignable to parameter of type…
42
votes
3 answers

react-router Redirect vs history.push

I was reading react-router-redux examples and I confused, what is the difference beetween: import { Redirect } from 'react-router-dom' ... and import { push } from 'react-router-redux' ... push('/login')
35
votes
6 answers

React Router work on reload, but not when clicking on a link

I have setup the React with react-router version 4. The routing works when I enter the URL directly on the browser, however when I click on the link, the URL changes on the browser (e.g http://localhost:8080/categories), but the content don't get…
32
votes
5 answers

How to dispatch Redux action from stateless component when route is loaded?

Goal: when loading a react-router route, dispatch a Redux action requesting asynchronic Saga worker to fetch data for the underlying stateless component of that route. Problem: stateless components are mere functions and don't have lifecycle…
Kitanotori
  • 1,531
  • 3
  • 14
  • 22
25
votes
5 answers

React Router: Cannot read property 'pathname' of undefined

I've just started learning React and got stuck at this error. Uncaught TypeError: Cannot read property 'pathname' of undefined at new Router Here is my code: var React = require('react'); var ReactDOM = require('react-dom'); var { Route,…
Alon
  • 443
  • 1
  • 4
  • 16
25
votes
1 answer

Get the current path in a react component

To determine the styling of specific menu item, I am trying to get the current path in my Navigation component. I tried some of the usual suspects already, but cannot get any results. Especially properties that I thought would be injected via React…
Anna Melzer
  • 914
  • 3
  • 9
  • 20
18
votes
2 answers

getting 404 for links with create-react-app deployed to github pages

I'm trying to deploy a create-react-app to a relative path on GitHub pages with a custom domain. E.g. www.example.com/myproject I'm using react-router-dom, react-router-redux and react-router-bootstrap I've set homepage to…
szerte
  • 365
  • 1
  • 2
  • 11
16
votes
3 answers

React-router Link, pass in params

If you have a route such as: And then you export that route, and so it can be used across your app, such as: export const MY_ROUTE = '/users/:userId/'; How do you set the param in a link…
Elliot
  • 12,770
  • 29
  • 76
  • 116
16
votes
3 answers

React-Router: how to wait for an async action before route transition

Is it possible to call an async redux action known as a thunk on a particular route and not perform the transition until the response has succeeded or failed? Use Case We need to load data from the server and fill a form with initial values. These…
AndrewMcLagan
  • 11,928
  • 19
  • 75
  • 144
14
votes
2 answers

Trying to setup redux history so I can redirect

I am trying to following this react router redux so I can redirect using the push('/') in my components or actions. Tutorial: https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux I am not sure what I missing but I am…
Blankman
  • 236,778
  • 296
  • 715
  • 1,125
1
2 3
33 34