node.js - Send prop to ReactJs from Express response (render) -
i have simple application node.js, express, passport , react-js.
i have index.html
includes client.js
simple render of react-js:
var react = require('react'); var react = require('react-dom'); var client = require('./client.jsx'); reactdom.render( react.createelement(client, null), document.getelementbyid('main') );
client
real application.
on server side (routes.js
) have this: app.get('/login', function(req, res){ res.render('login'); });
app.get('/auth/google', passport.authenticate('google', { scope: ['profile', 'email'] }),function(req, res){}); app.get('/auth/google/callback',passport.authenticate('google', { failureredirect: '/login' }), function(req, res) { res.redirect('/'); }); app.get('/', ensureauthenticated ,function(req, res){ req.session.id = req.user._id; //from mongodb res.render('index', { user: req.user }); }); function ensureauthenticated(req, res, next) { if (req.isauthenticated()) { return next(); } res.redirect('/login') }
i want send information loged user (username, real name, avatar, , others) top hierarchy react-js component.
- the way go use cookies?
- using express-session use cookies right?
- can update flux (reflux.js) store express on response?
- is there way send props top reactjs component (
client
)? don't handle cookies if there no other way use cookies.
Comments
Post a Comment