Which life cycle of an LWC does it receive a value from aura?
I know it may be a simple question, but I'm passing url parameters received in my aura component and passing it to my LWC, like this: I want in my LWC to call an apex method as soon as the id is received from my aura component. Which life cycle is it? Connected or rendered? Or maybe the constructor? I want to use the most efficient way to automatically call that apex method. Thanks for the help!
I ran a test on 10 loads each of a setter based call and a connectedCallback based call. Turns out that the average finish time of the function is (I think) statistically significantly faster via the connectedCallback
Average time for the setter based call was 445ms Average time for the connectedCallback based call was 408ms That's nearly 10% quicker. I haven't tested a wired callback... I may do that later today. Here's the code I used
(apex method just returns a string):_recordId; @api set recordId(value) { this._recordId = value; //console.time('setter'); //this.callTestMethodDeleteMe() } get recordId() { return this._recordId; } connectedCallback(){ console.time('connectedCallback'); this.callTestMethodDeleteMe(); } callTestMethodDeleteMe() { testMethodDeleteMe({}) .then((result) => { //console.timeEnd('setter'); console.timeEnd('connectedCallback'); }) .catch((error) => { console.log(error); }); }<br>