Profile redesign: Add Intl.Segmenter fallback (#38456)

This commit is contained in:
Echo
2026-03-27 16:15:36 +01:00
committed by GitHub
parent 43adb2c91d
commit 9a076359b9

View File

@@ -1,9 +1,9 @@
import { useMemo } from 'react';
import { FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import { length } from 'stringz';
import { polymorphicForwardRef } from '@/types/polymorphic';
import classes from './styles.module.scss';
@@ -14,8 +14,6 @@ interface CharacterCounterProps {
recommended?: boolean;
}
const segmenter = new Intl.Segmenter();
export const CharacterCounter = polymorphicForwardRef<
'span',
CharacterCounterProps
@@ -31,10 +29,7 @@ export const CharacterCounter = polymorphicForwardRef<
},
ref,
) => {
const currentLength = useMemo(
() => [...segmenter.segment(currentString)].length,
[currentString],
);
const currentLength = length(currentString);
return (
<Component
{...props}