-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
  • 92,299
  • 16
  • 152
  • 142
batt
  • 2,922
  • 2
  • 9
  • 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,159
  • 2
  • 15
  • 31