@excentone/spfx-react
Version:
Contains custom ReactJs components and hooks intended to use when developing SharePoint Framework (SPFx) Web components.
30 lines (29 loc) • 1.26 kB
TypeScript
import { ISpfxComponentUser } from "@excentone/spfx-core-lib";
import { Context } from "react";
/**
* The properties for `UserIdentityContext`.
* @see https://medium.com/swlh/avoid-prop-drilling-with-react-context-a00392ee3d8
* @template TUser The type of SharePoint component user.
*/
export interface IUserIdentityContextProps<TUser extends ISpfxComponentUser> {
/**
* The details of the current user.
*/
currentUser: TUser;
}
/**
* The type of context to be used for user identity.
*
* @template TUser The type of SharePoint component user.
*/
export declare type UserIdentityContext<TUser extends ISpfxComponentUser> = Context<IUserIdentityContextProps<TUser>>;
/**
* The type of custom hook to access the values of `UserIdentityContext`.
*
* @template TUser The type of SharePoint component user.
*/
export declare type UserIdentityHook<TUser extends ISpfxComponentUser> = () => IUserIdentityContextProps<TUser>;
/**
* Returns the type of {@link ISpfxComponentUser} specified for {@link IUserIdentityContextProps<TUser>} or {@link UserIdentityContext<User>}
*/
export declare type GetUserIdentityType<T> = T extends IUserIdentityContextProps<infer User> ? User : T extends UserIdentityContext<infer User> ? User : never;