@slashid/react
Version:
React SDK for the /id platform
49 lines • 1.17 kB
TypeScript
import { ReactNode } from "react";
type Props = {
belongsTo: string | ((groups: string[]) => boolean);
children: ReactNode;
};
/**
* Conditional rendering helper.
*
* Use this component where some content should be shown only to users belonging to one or more specific groups.
*
* @param belongsTo group name or predicate function - the predicate function is called with a list of group names that the user belongs to.
*
* @example
* User belongs to group "admin"
* ```tsx
* <Groups
* belongsTo="admin"
* >
* ...
* </Groups>
* ```
*
* @example
* User belongs to either "admin" or "user"
* ```tsx
* <Groups
* belongsTo={Groups.some("admin", "user")}
* >
* ...
* </Groups>
* ```
*
* @example
* User belongs to both "admin" and "user"
* ```tsx
* <Groups
* belongsTo={Groups.all("admin", "user")}
* >
* ...
* </Groups>
* ```
*/
export declare const Groups: {
({ belongsTo, children }: Props): import("react/jsx-runtime").JSX.Element | null;
some(...groups: string[]): (userGroups: string[]) => boolean;
all(...groups: string[]): (userGroups: string[]) => boolean;
};
export {};
//# sourceMappingURL=index.d.ts.map