Fix property empty issue

This commit is contained in:
Yang Luo
2023-08-14 12:09:38 +08:00
parent 891e8e21d8
commit b7a001ea39
7 changed files with 68 additions and 22 deletions

View File

@ -17,7 +17,7 @@ import {MetaMaskAvatar} from "react-metamask-avatar";
class AccountAvatar extends React.Component {
render() {
const {src, size} = this.props;
const {src, size, width, height} = this.props;
// The avatar for Metamask account is directly generated by an algorithm based on the address
// src = "metamask:0xC304b2cC0Be8E9ce10fF3Afd34820Ed306A23600";
const matchMetaMask = src.match(/^metamask:(\w+)$/);
@ -27,9 +27,19 @@ class AccountAvatar extends React.Component {
<MetaMaskAvatar address={address} size={size} />
);
}
return (
<img width={size} height={size} src={src} />
);
if (size !== undefined) {
return (
<img width={size} height={size} src={src} />
);
} else if (width === undefined) {
return (
<img height={height} src={src} />
);
} else if (height === undefined) {
return (
<img width={width} src={src} />
);
}
}
}