useGroups

useGroups(options?: GroupsOptions, deps?: any[]): ISiteGroupInfo[] | null | undefined;

Returns group collection. Use GroupsOptions.userId property to get groups for specific user.

Examples

Get all groups,

const groups = useGroups();

Get groups for a specific user,

const userGroups = useGroups({
	userId: 20
});

const userGroupsByEmail = useGroups({
	userId: "user@example.onmicrosoft.com"
});

const userGroupsByLoginName = useGroups({
	userId: "i:0#.f|membership|user@example.onmicrosoft.com"
});

Parameters

NameTypeDescriptionTracked for changes
options?GroupsOptionsuseGroups hook optionsPartially
deps?DependencyListHook dependency list.Yes