How to use Redirect in version 5 of react-router-dom of Reactjs

I am using the last version react-router module, named react-router-dom, that has become the default when developing web applications with React. I want to know how to make a redirection after a POST request. I have been making this code, but after the request, nothing happens. I review on the web, but all the data … Read more

How to tell webpack dev server to serve index.html for any route

React router allows react apps to handle /arbitrary/route. In order this to work, I need my server to send the React app on any matched route. But webpack dev server doesn’t handle arbitrary end points. There is a solution here using additional express server. How to allow for webpack-dev-server to allow entry points from react-router … Read more

React-Router: No Not Found Route?

Consider the following: var AppRoutes = [ <Route handler={App} someProp=”defaultProp”> <Route path=”https://stackoverflow.com/” handler={Page} /> </Route>, <Route handler={App} someProp=”defaultProp”> <Route path=”https://stackoverflow.com/” handler={Header} > <Route path=”/withheader” handler={Page} /> </Route> </Route>, <Route handler={App} someProp=”defaultProp”> <Route path=”:area” handler={Area} /> <Route path=”:area/:city” handler={Area} /> <Route path=”:area/:city/:locale” handler={Area} /> <Route path=”:area/:city/:locale/:type” handler={Area} /> </Route> ]; I have an App Template, a … Read more

How do you programmatically update query params in react-router?

I can’t seem to find how to update query params with react-router without using <Link/>. hashHistory.push(url) doesn’t seem to register query params, and it doesn’t seem like you can pass a query object or anything as a second argument. How do you change the url from /shop/Clothes/dresses to /shop/Clothes/dresses?color=blue in react-router without using <Link>? And … Read more

Pass props in Link react-router

I am using react with react-router. I am trying to pass property’s in a “Link” of react-router var React = require(‘react’); var Router = require(‘react-router’); var CreateIdeaView = require(‘./components/createIdeaView.jsx’); var Link = Router.Link; var Route = Router.Route; var DefaultRoute = Router.DefaultRoute; var RouteHandler = Router.RouteHandler; var App = React.createClass({ render : function(){ return( <div> <Link … Read more

React.createElement: type is invalid — expected a string

Trying to get react-router (v4.0.0) and react-hot-loader (3.0.0-beta.6) to play nicely, but getting the following error in the browser console: Warning: React.createElement: type is invalid — expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in. index.js: … Read more

How to get rid of underline for Link component of React Router?

I have the following: How do I get rid of the blue underline? The code is below: <Link to=”first”><MenuItem style={{paddingLeft: 13, textDecoration: ‘none’}}> Team 1 </MenuItem></Link> The MenuItem component is from http://www.material-ui.com/#/components/menu 31 Answers 31 I see you’re using inline styles. textDecoration: ‘none’ is used in child, where in fact it should be used inside … Read more

react-router vs react-router-dom, when to use one or the other?

Both have Route, Link, etc. When to use one or the other? I’m really confused on where to use each one. Server side? Client side? https://reacttraining.com/react-router/ In some examples you need to pass the history, in others not. What to do? <Router history={browserHistory}> vs <Router> It’s really confusing on when to use one or the … Read more

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 issue but it didn’t work. Any suggestions about this? 33 Answers 33 but classes … Read more