selectCurrentUser
Home > @gooddata/sdk-ui-dashboard > selectCurrentUser
selectCurrentUser variable
This selector returns current logged in user.
Signature:
selectCurrentUser: DashboardSelector<IUser>
Remarks
It is expected that the selector is called only after the permission state is correctly initialized. Invocations before initialization lead to invariant errors.
Example
- on how to use selectCurrentUserselector within a Dashboard Plugin.
// create the component using current user selector
const Greetings = () => {
     // read the currently logged in user information
     const user = useDashboardSelector(selectCurrentUser);
     return <div>Hello, {user.fullName}</div>;
}
// in a plugin's register function just use the component as a custom widget type
customize.customWidgets().addCustomWidget("greetingsWidget", Greetings);
 customize.layout().customizeFluidLayout((_layout, customizer) => {
         customizer.addSection(
             0,
             newDashboardSection(
                 "Greetings by Plugin",
                 newDashboardItem(newCustomWidget("greetings", "greetingsWidget"), {
                     xl: {
                         // all 12 columns of the grid will be 'allocated' for this new item
                         gridWidth: 12,
                         // minimum height since the custom widget now has just some one-liner text
                         gridHeight: 1,
                     },
                 }),
             ),
         );
     });