Created
November 22, 2014 13:12
-
-
Save kenwheeler/83cd06bbb9b767b5e63b to your computer and use it in GitHub Desktop.
Router?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Getting this error | |
// | |
// var html = React.renderToString(<Handler params={params}/>, document.body) | |
// ^ | |
// SyntaxError: Unexpected token < | |
// | |
// | |
// React | |
var React = require('react'); | |
require('node-jsx').install(); | |
var Router = require('react-router'); | |
var routes = require('./routes.js'); | |
// ... | |
app.get('*', isLoggedIn, function(req,res){ | |
LinkActions.loadLinks(links); | |
UserActions.loadUser(req.user ? req.user.twitter : []); | |
Router.run(routes, Router.HistoryLocation, function (Handler, state) { | |
var params = state.params; | |
var html = React.renderToString(<Handler params={params}/>, document.body); | |
res.render('index', { | |
markup: html, | |
links: JSON.stringify(links), | |
user: req.user ? JSON.stringify(req.user.twitter) : "[]" | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment