feat: identicon

This commit is contained in:
jialin
2025-10-17 10:15:55 +08:00
parent 005295ac97
commit 49c6bb71a1
3 changed files with 47 additions and 4 deletions
+26
View File
@@ -0,0 +1,26 @@
import jdenticon from 'jdenticon';
import React, { useEffect, useRef } from 'react';
interface IdenticonProps {
value: string;
size: number;
}
const Identicon: React.FC<IdenticonProps> = ({
value = 'test',
size = 28
}: IdenticonProps) => {
const icon = useRef<any>(null);
useEffect(() => {
jdenticon?.update(icon.current, 'value');
}, [value]);
return (
<>
<svg data-jdenticon-value={value} height={size} ref={icon} width={size} />
</>
);
};
export default Identicon;