I am currently working on a project using NodeJS, Express, Flux and React, along with React Router for client side routing.
I may have the wrong idea of how the process should be working, but I am currently attempting to redirect the user to the home screen following a successful login. Unfortunately a lot of examples I'm finding for React Router are for Pre-Version 1.0 and are now irrelevant, or are in ES6 which I am not currently writing in so I have been trying to follow examples and tie things together as best I can.
My code is below -
// main.js
var React = require('react/addons');
var Components = require('./components');
var Flux = require('./flux');
var ReactRouter = require('react-router');
var Router = ReactRouter.Router;
var Route = ReactRouter.Route;
var RouterStore = require('./flux/stores/RouterStore.js');
var routes = require('./routes.js');
var AppRouter = React.render(<Router>{routes}</Router>, document.getElementById('render-target'));
RouterStore.setRouter(AppRouter);
/
// routes.js
"use strict";
var React = require('react');
var Router = require('react-router');
var DefaultRoute = Router.DefaultRoute;
var Route = Router.Route;
var routes = (
<Router>
<Route path="/" component={require('./components/pageComponents/HomePage.jsx')} />
<Route path="item(/:id)" component={require('./flux/viewComponents/Item_ViewComponent.jsx')} />
<Route path="login" component={require('./flux/viewComponents/Login_ViewComponent.jsx')} />
</Router>
)
module.exports = routes;
At this point, after following examples and gleaning information from sources like the one here Automatic redirect after login with react-router
I thought I should then be able to call transitionTo on the router object that is now in my store. However this method is not defined, and nor is it defined on any of the other objects I have created.
Am I fundamentally thinking about this the wrong way? Or have I simply combined one too many examples and fudged the configuration?
Thanks