activeUser
Description
Optional. Identifies the current user in the comments widgetUsage
activeUser?: string | number | {
id: string | number;
name?: string;
avatar?: string;
color?: string;
};
Parameters
The property accepts one of the following types:
- string | number - the ID of the current user.Must match the id field of a user object from the users array
- a user object with the following fields:
interface IUser {
id: string | number; // required, unique identifier of the user
name?: string; // optional, display name of the user
avatar?: string; // optional, URL of the user's avatar image
color?: string; // optional, color used for styling the user's comments
}
Examples
Defining current user
import { Comments } from '@svar-ui/react-comments';
const users = [
{ id: 1, name: 'John Doe' },
{ id: 2, name: 'Jane Doe' },
];
export default function App() {
const value = []; // current comments value
return <Comments value={value} users={users} activeUser={1} />;
}
In this example, the active user is set to the user with ID 1. Comments made by this user can be edited or deleted through the UI and will have separate styling.
Details
The property controls the ability to edit or delete comments made by this user and applies specific styling to those comments. The default value is null
.