Add forward ref in avatar component
authorAjay Bura <ajbura@gmail.com>
Tue, 8 Mar 2022 10:59:01 +0000 (16:29 +0530)
committerAjay Bura <ajbura@gmail.com>
Tue, 8 Mar 2022 10:59:01 +0000 (16:29 +0530)
Signed-off-by: Ajay Bura <ajbura@gmail.com>
src/app/atoms/avatar/Avatar.jsx

index 6120e55111f58cb9a119a3d73244c2cb6f671f87..fc46c250453e0648f9b97ddd34de371a13c8d8cd 100644 (file)
@@ -10,16 +10,16 @@ import RawIcon from '../system-icons/RawIcon';
 import ImageBrokenSVG from '../../../../public/res/svg/image-broken.svg';
 import { avatarInitials } from '../../../util/common';
 
-function Avatar({
+const Avatar = React.forwardRef(({
   text, bgColor, iconSrc, iconColor, imageSrc, size,
-}) {
+}, ref) => {
   let textSize = 's1';
   if (size === 'large') textSize = 'h1';
   if (size === 'small') textSize = 'b1';
   if (size === 'extra-small') textSize = 'b3';
 
   return (
-    <div className={`avatar-container avatar-container__${size} noselect`}>
+    <div ref={ref} className={`avatar-container avatar-container__${size} noselect`}>
       {
         imageSrc !== null
           ? (
@@ -50,7 +50,7 @@ function Avatar({
       }
     </div>
   );
-}
+});
 
 Avatar.defaultProps = {
   text: null,