reactjs - How to pass variable to react component -


for example, create react component this

var hellomessage = react.createclass({   render: function() {     return <div>hello {this.props.name}</div>;   } });  reactdom.render(<hellomessage name="john" />, mountnode); 

so can pass message variable server? this

reactdom.render(<hellomessage name="{{ message }}" />, mountnode); 

what you're trying should work. can instantiate javascript variable showed, have reactdom.render call rendered in view server-side. no need render react component server-side, have render call rendered on page.

for example, in javascript file, have component (hellomessage) showed.

then, render second snippet of code (server-side) on page:

<script type="text/javascript">     reactdom.render(<hellomessage name="{{ message }}" />, mountnode); </script> 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -