H
H
hbrmdc2015-06-10 17:35:40
JavaScript
hbrmdc, 2015-06-10 17:35:40

How to make variable from array.map?

Briefly:

this.data.comments.map(function(c) {
  return <li>{c.text}</li>;
})

How to make variable from c.text?
Detail:
I get an array:
observe: function() {
    return {
      newEstateData: (new Parse.Query('newEstateData')).ascending('createdAt')
    };
  },

from this array I create an output template (sorry if the terminology is not correct):
{this.data.newEstateData.map(function(c) {
          return (
    <div className="some classes">{c.columnName}</div>
    // и тут создаю кнопку для роутера
    <Link to="NewEstateDetails" params={{id: "Сюда нужно поместить id из array" }} className="btn-flat cyan-text fullwidth center waves-effect waves-teal">Подробнее</Link>

  )
        })},

How to put id from array in params?
ps. to stick an id right in the middle of the code, just write {c.objectId}.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valentin Dubrovsky, 2015-06-10
@matroskin13

array.map(function(item, i){
    // i - это ключ
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question