@liveblocks/react-ui
Version:
A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.
27 lines (23 loc) • 953 B
JavaScript
"use client";
import { jsx } from 'react/jsx-runtime';
import { useUser } from '@liveblocks/react';
import { useMemo } from 'react';
import { useOverrides } from '../../overrides.js';
import { useCurrentUserId } from '../../shared.js';
import { classNames } from '../../utils/class-names.js';
function User({ userId, replaceSelf, className, ...props }) {
const currentId = useCurrentUserId();
const { user, isLoading } = useUser(userId);
const $ = useOverrides();
const resolvedUserName = useMemo(() => {
return replaceSelf && currentId === userId ? $.USER_SELF : user?.name ?? $.USER_UNKNOWN;
}, [replaceSelf, currentId, userId, $.USER_SELF, $.USER_UNKNOWN, user?.name]);
return /* @__PURE__ */ jsx("span", {
className: classNames("lb-name lb-user", className),
"data-loading": isLoading ? "" : void 0,
...props,
children: isLoading ? null : resolvedUserName
});
}
export { User };
//# sourceMappingURL=User.js.map