Skip to main content

Provisioning data via @wire is asynchronous. In your template you need to guard against this.rec.data being undefined which is the case until data is provisioned.

<template>
  <template if:true={rec.data}>
    ({idx} {name}
  </template>
</template>

In your JavaScript add a getter for name.

import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
...
get name() {
  return getFieldValue(this.rec.data, ‘Trip__c.Name');
}

A functioning example using this pattern is https://github.com/trailheadapps/lwc-recipes/tree/master/force-app/main/default/lwc/wireGetRecordUser

Provisioning data via @wire is asynchronous. In your template you need to guard against this.rec.data being undefined which is the case until data is provisioned.

<template>
  <template if:true={rec.data}>
    (idx} {name}
  </template>
</template>

In your JavaScript add a getter for name.

import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
...
get name() {
  return getFieldValue(this.rec.data, ‘Trip__c.Name');
}

A functioning example using this pattern is https://github.com/trailheadapps/lwc-recipes/tree/master/force-app/main/default/lwc/wireGetRecordUser

Provisioning data via @wire is asynchronous. In your template you need to guard against this.rec.data being undefined which is the case until data is provisioned.

<template>
  <template if:true={rec.data}>
    {idx} {name}
  </template>
</template>

In your JavaScript add a getter for name.

import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
...
get name() {
  return getFieldValue(this.rec.data, ‘Trip__c.Name');
}

A functioning example using this pattern is https://github.com/trailheadapps/lwc-recipes/tree/master/force-app/main/default/lwc/wireGetRecordUser

Source Link

Provisioning data via @wire is asynchronous. In your template you need to guard against this.rec.data being undefined which is the case until data is provisioned.

<template>
  <template if:true={rec.data}>
    (idx} {name}
  </template>
</template>

In your JavaScript add a getter for name.

import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
...
get name() {
  return getFieldValue(this.rec.data, ‘Trip__c.Name');
}

A functioning example using this pattern is https://github.com/trailheadapps/lwc-recipes/tree/master/force-app/main/default/lwc/wireGetRecordUser