javascript - react function not being called -


i rendering react class using node js so...

var express = require('express'); var router = express.router();  var react = require('react'); var reactdom = require('react-dom/server'); var app = react.createfactory(require('../components/index'));  router.get('/', function(req,res) {     var reacthtml = reactdom.rendertostring(app({}));     res.render('../../tutorhub/views/index.jade', {reactoutput: reacthtml}); }); module.exports = router; 

the page gets rendered fine, no function add gets called. example, in app class...

class app extends react.component {     constructor(props) {         super(props);         }     getclass() {         return "a_class";     }      render() {         return (             <div classname={this.getclass}></div>         );     } }  module.exports = app; 

the getclass function not called. instead classname becomes code

class = getclass() {     return "a_class"; } 

instead of a_class when check html. reason, rather function being called, saved string , placed in classname.

why happening? not able call functions make. can me out?

the function isn't called because didn't call it. can see function's source, because function gets coerected string same ((""+(foo=>bar)) === "foo=>bar"). have is:

<div classname={this.getclass()}></div> 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -