What I understand from documentation is that we cannot access child component elements inside connectedcallback because they're not yet created - that means they don't exist yet. However, we can access the elements from the host component/ component in which connectedcallback resides. I tried using queryselector in all connectedcallback, renderedcallback and disconnectedcallback and end up getting null value everywhere. No sure what's wrong.
HTML
<template>
<lightning-card title ="LifeCycle Hooks!!">
<div>
<p data-id={sMessage}>{sMessage}</p>
</div>
</lightning-card>
</template>
JS
connectedCallback(){
console.log('This is connectedcallback');
console.log('Query Selector : ' ,this.template.querySelector('p'));
console.log('Query Selector this: ' ,this.querySelector('p'));
console.log('Greeting connectedcallback: ',this.sGreeting)
this.sGreeting+='??';
console.log('Updated Greeting connectedcallback! : ',this.sGreeting)
}
This is how console looks. Can someone please help me understand what I'm missing here?