permissionKind returns void in React

Copper Contributor

I have a search function that returns all list items including their parent link based on their content type, tenant-wide.

 

Every list item comes from a specific subsite and I want to split the output for the following:

One kind of items where the current user is a member of the parent site of the said item. The idea is that these items should be displayed as “my items”.

 

And the total oppsoite from above – items where the current user is not member of their parentsite. Idea here is to show them as “other items” where the user can click on these items, get to the parent subsite and manually request access for that site (they dont have read permission by default).

 

So I try to make a function that checks every list items parent link and sees if the current user is a member of that particular site the link points to, and if so, display the items

 

 public getPermissions() { 

      const { listItems } = this.state; 

 {listItems.length > 0 && listItems.map((item: Project) => { 

   let web = new Web(item.ListUrl); 

    web.getCurrentUserEffectivePermissions().then(perms => {  

     if (web.hasPermissions(perms, PermissionKind.ViewPages)) { 

       return {__html: item.Title}  

   } } ) } 
            )}} 

I try to call it:

 

public render() {

return (

   <div dangerouslySetInnerHTML={this.getPermissions()} />
      )   }   } 

 

But I get an error at the return:

"Types of property 'dangerouslySetInnerHTML' are incompatible. Type 'void' is not assignable to type '{ __html: string; }'. (method) GetSpListItems.getPermissions(): void"

 

Why does the function return void?

0 Replies