LWC: wire apex to property with @api param value
Define a setter-getter for tripId
and use it to extract the @wire
configuration value.
Here's what that looks like:
tripId; // value to use with @wire
_trip; // private var used with getter-setter
@api
set trip(value) {
this._trip = value;
this.tripId = value.Id; // extract the value
}
get trip() { return this._trip; }
@wire(getTickets, { recordId: '$tripId' }) tickets;
This approach with a getter-setter is preferred over other solutions (eg a getter only on tripId) because it'll keep this.tripId up to date whenever this.trip is changed.