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
Answer
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);
No comments:
Post a Comment