Is there a good practice to conditionnaly get data from a component when this data can be passed by a parent?
Eg: I have a component that relies on data which he can get through a wire call or through a parent component, depending on its context (standalone or integrated in another component which will get the data for its child)
Current solution I use is to imperatively call my backend in the connectedCallback() :
import myFunc from '@salesforce/apex/...';
MyComponent () {
@api recordId;
@api data;
@track _myFinalData; // to be used by the component
connectedCallback() {
if (this.data == null && this.recordId != null) {
myFunc()
.then(result => {
this._myFinalData = result;
})
} else {
this._myFinalData = this.data;
}
}
}