You need to sign in to do that
Don't have an account?

LWC pass wire value to the connectedCallback
Hello All,
I am trying to pass a value from @wire to the connectedCallback
So process flow is
So at step 3 the @wire gets a value but not a step 1
What am I doing wrong?
Thank you,
P
I am trying to pass a value from @wire to the connectedCallback
import PRICE_FIELD from '@salesforce/schema/Order__c.Price__c';
@wire(getRecord, { recordId: '$recordId', fields: [PRICE_FIELD] }) record;I tried this within the connectedcallback but no value
this.priceId = this.record.data ? getFieldValue(this.record.data, PRICE_FIELD) : '';
So process flow is
- @wire
- callback
- @wire
So at step 3 the @wire gets a value but not a step 1
What am I doing wrong?
Thank you,
P
Create one container div inside template tag and add attributes lwc:dom="manual" in your html file
<template> <div class="container" lwc:dom="manual"></div> </template>
All Answers
Hi
Connected call back is alway run before component is initialized.
if u want to get value in connectedcallback then u have to call getRecord inside connectedcallback like belove
connectedcallback(){
getRecord({ recordId: '$recordId', fields: [PRICE_FIELD] })
.then(result => {
console.log({result})
})
.catch(err => { console.log({err})});
}
"[LWC error]: The `appendChild` method is available only on elements that use the `lwc:dom=\"manual\"` directive."
ANy thoughts on the error message?
Thank you,
P
Create one container div inside template tag and add attributes lwc:dom="manual" in your html file
<template> <div class="container" lwc:dom="manual"></div> </template>