-1

I'm new on React, could you say me what's the meaning of this?

const new_venues = this.state.venues.map((venue) =>
 place_id === venue.place_id ? { ...venue, open : !venue.open } : { ...venue, open: false });

I know the syntax cond ? cond_true : cond:false, but I don't know the meaning of ...venue

Mayank Shukla
  • 100,735
  • 18
  • 158
  • 142
batt
  • 3,382
  • 2
  • 11
  • 12

1 Answers1

2

This is the spread syntax. See these docs

It is a shorthand method for adding all the properties of the specified object (in your case venue) to a new object. Prior to this, the equivalent was to use Object.assign() (docs)

const newObject = Object.assign({}, venue);
Anthony
  • 6,422
  • 2
  • 17
  • 34