Archives : March-2016

How to check if generic react-router path matches current location pathname? react-router path: /Movies/:id location.pathname: /Movies/56fa7446bae6eb301e5937f3 I want to use route paths with menu buttons, to set class=”active”. EDIT: To clarify, paths in my app look like: /Movies/56fa7/watch and not like: /Movies/watch/56fa7 How do I check if the former route is active? Is it doable ..

Read more

I just started learning React, I’m trying to make a SPA blog, which has a global positioned fixed header. import React from ‘react’; import { render } from ‘react-dom’; // import other components here render(( <Router history={browserHistory}> <Route path=”/” component={Home} /> <Route path=”/About” component={About} /> <Route path=”/Contact” component={Contact} /> <Route path=”*” component={Error} /> </Router> ), ..

Read more

I am using react-router 2. My routes are defined as <Route path=”/” component={App}> <IndexRoute component={Home}/> <Route path=”/about” component={About}/> <Route path=”/login” component={Login} onEnter={redirectToDashboard}/> <Route path=”/logout” component={Logout} onEnter={logoutSession}/> <Route path=”/dashboard” component={Dashboard} onEnter={redirectToLogin}/> </Route> Everything working fine but I am having problem disabling back button from my dashboard page. After successful login I am redirecting user to dashboard ..

Read more

I would like to make use of react-router’s onEnter handler in order to prompt users to authenticate when entering a restricted route. So far my routes.js file looks something like this: import React from ‘react’; import { Route, IndexRoute } from ‘react-router’; export default ( <Route path=”/” component={App}> <IndexRoute component={Landing} /> <Route path=”learn” component={Learn} /> ..

Read more

React-router is off to a really bad start… What seems basic doesn’t work. Using react-router 2.0.0 my Link component updates the URL to be /about, but my page doesn’t render the About component after that… Entry point js var React = require(‘react’); var ReactDOM = require(‘react-dom’); var Router = require(‘react-router’).Router; var Route = require(‘react-router’).Route; var ..

Read more

I’m trying to configure React Router so that when accessing http://url/manage/roomId it goes directly to http://url/manage/roomId/sessions (loading RoomSessions component). These are tabs components’ routes and I want to load the first tab’s content (which it does) by default with the proper URL (which it does not). It works fine except for the redirection <Route path="manage/:roomId" ..

Read more