I need to display content based on the group the current user belongs to but can't figure out how to do this in react/pnpjs.
I wrote the function below but it returns false even when the group name returned in console.log(grp["Title"]) is correct.
private _checkUserInGroup(strGroup)
{
let InGroup:boolean = false;
let grp = sp.web.currentUser.groups.get().then((r: any) => {
r.forEach((grp: SiteGroups) =>{
if (grp["Title"] == strGroup)
{
InGroup = true;
}
console.log(grp["Title"]);
});
});
return InGroup;
}