GPP
GPP

Reputation: 2315

What does the : symbol mean in React createClass() method?

Here's some sample code from ReactKungfu:

var CommentBox = React.createClass({
  render: function() {
    return (
      <div className="commentBox">
        Hello, world! I am a CommentBox.
      </div>
    );
  }
});

What does the : in render: function() signify? I haven't seen this explained in vanilla JS tutorials I have done, although I believe it signifies "[something] in [this other list/range] in Java

Upvotes: 1

Views: 34

Answers (1)

Julxzs
Julxzs

Reputation: 737

The curly brackets you put around the data passed into the function represent a JS object. render is simply a member variable of that object, so the : is to define that variable as the function after it.

It's basically equivalent to let render = function() { ... } outside of an object.

Upvotes: 2

Related Questions