Created helper function to convert mutable refs from useRef into element refs for the ref prop

This commit is contained in:
Alejandro Celaya
2022-06-06 20:46:51 +02:00
parent b450e4093e
commit 7669254a0c
6 changed files with 18 additions and 21 deletions

View File

@@ -8,6 +8,7 @@ import { ShortUrl } from '../data';
import { SelectedServer } from '../../servers/data';
import { ShortUrlDetailLink } from './ShortUrlDetailLink';
import './ShortUrlVisitsCount.scss';
import { mutableRefToElementRef } from '../../utils/helpers/components';
interface ShortUrlVisitsCountProps {
shortUrl?: ShortUrl | null;
@@ -35,7 +36,7 @@ export const ShortUrlVisitsCount = (
}
const prettifiedMaxVisits = prettify(maxVisits);
const tooltipRef = useRef<HTMLElement | null>();
const tooltipRef = useRef<HTMLElement | undefined>();
return (
<>
@@ -43,9 +44,7 @@ export const ShortUrlVisitsCount = (
{visitsLink}
<small
className="short-urls-visits-count__max-visits-control"
ref={(el) => {
tooltipRef.current = el;
}}
ref={mutableRefToElementRef(tooltipRef)}
>
{' '}/ {prettifiedMaxVisits}{' '}
<sup>