Jose Cabrera Zuniga
Jose Cabrera Zuniga

Reputation: 2619

jsx syntax that confuses me

I saw the next code:

const cardSource = {
  beginDrag(props) {
    return {
      text: props.text
    };
  }
};

Typically I use {} for jsx block code or to build objects. cardSource makes me feel uneasy. Is beginDrag a member of cardSource? If so, can I use the call: cardSource.beginDrag()?

Upvotes: 0

Views: 44

Answers (1)

lorefnon
lorefnon

Reputation: 13095

Is beginDrag a member of cardSource?

Yes. This is equivalent to :

const cardSource = {
  beginDrag: function beginDrag(props) {
    return {
      text: props.text
    };
  }
};

If so, can I use the call: cardSource.beginDrag()?

Yes.

Upvotes: 1

Related Questions