useIsMemberOf

useIsMemberOf(
	groupId: string | number,
	options?: IsMemberOfOptions,
	deps?: any[]): [boolean, ISiteGroupInfo];

Returns users membership info for the specified group. Use IsMemberOfOptions.userId property to check another user. Default is current user.

Examples

Get current users membership info,

const [isMember, groupInfo] = useIsMemberOf(10);

Get different users membership info,

const [isMember, groupInfo] = useIsMemberOf("My SharePoint Group", {
	userId: "user@example.onmicrosoft.com"
});

const [isMember, groupInfo] = useIsMemberOf("My SharePoint Group", {
	userId: 25
});

const [isMember, groupInfo] = useIsMemberOf(10, {
	userId: "i:0#.f|membership|user@example.onmicrosoft.com"
});

Parameters

NameTypeDescriptionTracked for changes
groupIdstringGroup name or IdYes
options?IsMemberOfOptionsuseIsMemberOf hook optionsPartially
deps?DependencyListHook dependency list.Yes