Skip to content

Commit

Permalink
Merge branch 'LivePersona_Refractoring' of https://github.com/joaojme…
Browse files Browse the repository at this point in the history
…ndes/sp-dev-fx-controls-react into joaojmendes-LivePersona_Refractoring
  • Loading branch information
joelfmrodrigues committed Jan 29, 2022
2 parents 44e1bea + 5f30b47 commit 8a05549
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 deletions docs/documentation/docs/controls/LivePersona.md
Expand Up @@ -35,7 +35,7 @@ import { LivePersona } from "@pnp/spfx-controls-react/lib/LivePersona";
<Persona text="João Mendes" secondaryText="joao.j.mendes@sapteck.com" coinSize={48} />
</>
}
context={this.props.context}
serviceScope={this.context.serviceScope}
/>
```

Expand All @@ -47,7 +47,7 @@ The `LivePersona` control can be configured with the following properties:

| Property | Type | Required | Description |
| ---- | ---- | ---- | ---- |
| context | BaseComponentContext | yes | The context object of the SPFx loaded webpart or customizer. |
| serviceScope | ServiceScope | yes | The SPFx ServiceScope object loaded from context of web part or extension. |
| upn |string | yes | User UPN. |
| disableHover | boolean | no | If info should not appear on hover. |
| template | string \| JSX.ELement | yes | The content to wrap with persona info. |
| template | string | JSX.ELement | yes | The content to wrap with persona info. |
8 changes: 2 additions & 6 deletions src/controls/LivePersona/ILivePersonaProps.ts
@@ -1,13 +1,9 @@
import { BaseComponentContext} from "@microsoft/sp-component-base";
import { ServiceScope } from "@microsoft/sp-core-library";

export interface ILivePersonatProps {
/**
* The Web Part context
*/
context?: BaseComponentContext;

/**
* The Web Part context
* The service locator pattern used by the SharePoint Framework.
*/
serviceScope: ServiceScope;
/**
Expand Down
6 changes: 3 additions & 3 deletions src/controls/LivePersona/LivePersona.tsx
Expand Up @@ -13,7 +13,7 @@ export const LivePersona: React.FunctionComponent<ILivePersonatProps> = (
) => {
const [isComponentLoaded, setIsComponentLoaded] = useState<boolean>(false);
const sharedLibrary = useRef<any>();
const { upn, template, disableHover, context, serviceScope } = props;
const { upn, template, disableHover, serviceScope } = props;

useEffect(() => {
(async () => {
Expand All @@ -22,7 +22,7 @@ export const LivePersona: React.FunctionComponent<ILivePersonatProps> = (
sharedLibrary.current = await SPComponentLoader.loadComponentById(LIVE_PERSONA_COMPONENT_ID);
setIsComponentLoaded(true);
} catch (error) {
Log.error(`[LivePersona]`, error, serviceScope ?? context.serviceScope);
Log.error(`[LivePersona]`, error, serviceScope );
}
}
})();
Expand All @@ -38,7 +38,7 @@ if (isComponentLoaded) {
PersonaType: 'User'
},
upn: upn,
serviceScope: serviceScope ?? context.serviceScope,
serviceScope: serviceScope,
}, createElement("div",{},template));
}
return renderPersona;
Expand Down

0 comments on commit 8a05549

Please sign in to comment.