javascript - How to manually navigate to route with React + React-Router-Component -



javascript - How to manually navigate to route with React + React-Router-Component -

i've created react component library, js react page views render , control.

// application js, controls routes. var application = react.createclass({ mixins: [router], routes: { '/': homepage, '/users': performerpage // , null: notfoundpage }, render: function () { homecoming this.transferpropsto(this.renderroutehandler()); } }); // , in homeview.js, link page <link href={'/users'}>{'test'}</link>

this works wondefully. except when manually navigate link, doesn't handle yet... question is, if server redirects index always, react grab this? i'm pretty versed in grunt, , build automation in general, node js servers aren't forte yet unfortunately.

in grunt server

task => 'connect:livereload', 'webpack:development', 'open', 'watch'

final result: user should paste address bar (ie site.com/users) , navigated applications /users.

thanks :d help great.

one way set routes in own file (say client/routes.js)

module.exports = { '/': homepage, '/users': performerpage // , null: notfoundpage };

now can require them in application file, , in node server:

var app = require('express')(); var routes = object.keys(require('../client/routes')); routes.foreach(function(route){ app.get(route, function(req, res){ res.sendfile(__dirname + '/static/index.html'); }); });

javascript gruntjs reactjs

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -