fayemacapagal
fayemacapagal

Reputation: 13

I want to show the filtered search from an array, I cannot return it in front end

I want to display the Project Name and other indexes from filteredResults, how can I map it and its indexes? Or parsing?

I put it on onClick event:

function filter() {  
  var filteredResults = projectData.filter((f => f.ProjectName.includes(filterKeyword) && (f  => f.PartitionKey.includes(nameArea))));
  console.log(filteredResults);       
};

return:
  <Stack direction="row" id="projectResults">
    <Masonry columns={2} spacing={2}>
      {!!projectData && (
        projectData.map((card, index) => (
          <MasonryItem key={card.RowKey}>
            ...
          </MasonryItem>
        ))
      )}
    </Masonry>
  </Stack>

Upvotes: 0

Views: 51

Answers (1)

Harun Yilmaz
Harun Yilmaz

Reputation: 8558

Your filter callback is not valid.

Try changing it to this:

var filteredResults = projectData.filter(f => f.ProjectName.includes(filterKeyword) && f.PartitionKey.includes(nameArea));

Upvotes: 1

Related Questions