score:1

sample demo.

send webpart context to component(in .ts file)

const element: react.reactelement<iofficeuifabricprops > = react.createelement(
      officeuifabric,
      {
        description: this.properties.description,
        context: this.context       
      }
    )

update component(icomponent.ts file)

export interface iofficeuifabricprops {
  description: string;  
  context:any;
}

in tsx file

private _getlistdata(clientcontext): promise<any> {
    return clientcontext.sphttpclient.get(clientcontext.pagecontext.web.absoluteurl + `/_api/web/lists?$filter=hidden eq false`, sphttpclient.configurations.v1)
      .then((response?: any) => {
        return response.json();
      });
   }

render function

var testoptions=[];
    this._getlistdata(this.props.context).then((data: any) => {      
      for (let i: number = 0; i < data.value.length; i++) {
        //debugger;
        testoptions.push({key:data.value[i].id,text:data.value[i].title,});
      }      
    })    
    return (     
      <div >  
        <dropdown label="required dropdown example:" 
         options={testoptions}             
            /> 

enter image description here


Related Query

More Query from same tag