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