I would like to hide the above commandbar in all pages using javascript in spfx extensions(application customizer).
I have tried the below code
@override
public onInit(): Promise<void> {
return super.onInit().then(_ => {
pnp.setup({
spfxContext: this.context
});
}).then(()=>{
$(document).ready(()=>{
pnp.sp.web.currentUser.get().then(d=>{
pnp.sp.web.associatedOwnerGroup.users.getById(d.Id)
.get().then((data)=>{
console.log("Site Owner");
}).catch((error)=>{
console.log("Not Site Owner");
//hidding the button divs on banner for current users who are not owner
$(".commandBarWrapper").bind("load",()=>{
if($('.ms-CommandBar')){
$(".ms-CommandBar").hide();
}
});
});
});
});
}
Is there any other way to know if the component has been loaded?
Please help