mirror of https://github.com/msgbyte/tailchat
style: 优化UserAvatar 和 UserName 的props,允许接受更多的参数
parent
356e7edd58
commit
e27094d0f2
@ -1,13 +1,20 @@
|
||||
import React from 'react';
|
||||
import { useCachedUserInfo } from 'tailchat-shared';
|
||||
|
||||
export const UserName: React.FC<{
|
||||
interface UserNameProps {
|
||||
userId: string;
|
||||
className?: string;
|
||||
}> = React.memo((props) => {
|
||||
const { userId, className } = props;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
export const UserName: React.FC<UserNameProps> = React.memo((props) => {
|
||||
const { userId, className, style } = props;
|
||||
const cachedUserInfo = useCachedUserInfo(userId);
|
||||
|
||||
return <span className={className}>{cachedUserInfo.nickname}</span>;
|
||||
return (
|
||||
<span className={className} style={style}>
|
||||
{cachedUserInfo.nickname}
|
||||
</span>
|
||||
);
|
||||
});
|
||||
UserName.displayName = 'UserName';
|
||||
|
Loading…
Reference in New Issue