diff --git a/app/javascript/flavours/glitch/components/character_counter/index.tsx b/app/javascript/flavours/glitch/components/character_counter/index.tsx index 6ffe4d02f4..6bc88c23ac 100644 --- a/app/javascript/flavours/glitch/components/character_counter/index.tsx +++ b/app/javascript/flavours/glitch/components/character_counter/index.tsx @@ -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 (