Morgan Allen Morgan Allen - 1 year ago 79
React JSX Question

React: Calling methods inside a variable

I'm trying to run a simple React component and not sure why this isn't working.

For some reason,

isn't running. Can someone explain why?

var CreateRows = React.createClass({
addRows : function(){
return (


render: function(){
return (

Answer Source

You have to call the function with { this.addRows() }. With your code you are only referring to the function but not invoking it. Such a statement could be used for defining a function e.g. like onClick={ this.addRows }

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download