reactjs - Server side rendering with Swig template, React and Express -


this router set express:

var r = require('rethinkdb'); var quotes = require('../model/quotes'); var user = require('../model/users'); var auth = require('../lib/auth'); var react=require('react'); var reactdomserver=require('react-dom/server') var homepage=react.createfactory(require('../component/index.js').homepage);  module.exports = function(app, passport) {      app.get('/', function(req, res) {         if (req.user) {             res.redirect('/dashboard');         } else {             var homepagehtml=reactdomserver.rendertostring(homepage({}));             res.render('index',{homepage:homepagehtml});         }     });  } 

in index.html view, written in swig template engine:

{% extends 'main.html' %}  {% block title %}homepage{% endblock %}  {% block body %}     {{homepage}} {% endblock %} 

it renders string tags, not component created react, should make swig render component wrote?

have tried {{ homepage.tostring() }} ? think solve problem.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -