You need to sign in to do that
Don't have an account?
vinni shree
Hi I'm new to dev
Can someone please explain me when we use connected callback and wire methoda with small use case scenario, I know the defintiions of both but unable to use those at the right time.
Thank you
connectedCallback() in Lightning Web Component flows from parent to child. For Example if we have a parent and child component, connectedCallback() defined in parent component will get fire first then child component.
We can’t access child elements from the callbacks because they don’t exist yet.
It’s invoked after constructor hook fired.
If we want fire any logic on component load then we should use ConnectedCallBack() life cycle hook.
Refer the below links.
https://salesforcegirl.in/2021/06/14/connectedcallback-in-lwclightning-web-component/#:~:text=It's%20invoked%20after%20constructor%20hook,ConnectedCallBack()%20life%20cycle%20hook.
https://salesforce.stackexchange.com/questions/313806/connectedcallback-vs-renderedcallback-in-lightning-web-component
If this helps, Please mark it as best answer.
Thanks!!
All Answers
connectedCallback() in Lightning Web Component flows from parent to child. For Example if we have a parent and child component, connectedCallback() defined in parent component will get fire first then child component.
We can’t access child elements from the callbacks because they don’t exist yet.
It’s invoked after constructor hook fired.
If we want fire any logic on component load then we should use ConnectedCallBack() life cycle hook.
Refer the below links.
https://salesforcegirl.in/2021/06/14/connectedcallback-in-lwclightning-web-component/#:~:text=It's%20invoked%20after%20constructor%20hook,ConnectedCallBack()%20life%20cycle%20hook.
https://salesforce.stackexchange.com/questions/313806/connectedcallback-vs-renderedcallback-in-lightning-web-component
If this helps, Please mark it as best answer.
Thanks!!