Skip to content

Commit

Permalink
refactor: unpack value from rest
Browse files Browse the repository at this point in the history
  • Loading branch information
feclist committed Nov 12, 2024
1 parent 36485f7 commit 6730d1c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const TextArea = forwardRef(
maxLength,
allowExceedingMaxLength,
onChange,
value,
resize = true,
showCharCount = false,
...rest
Expand All @@ -41,7 +42,7 @@ const TextArea = forwardRef(
const helpTextId = helpText && `${id}-help-text`;
const allowExceedingMaxLengthTextId = allowExceedingMaxLength && `${id}-allow-exceeding-max-length`;

const [characterCount, setCharacterCount] = useState(rest.value?.length || 0);
const [characterCount, setCharacterCount] = useState(value?.length || 0);

const handleOnChange = useCallback(
(event: React.ChangeEvent<HTMLTextAreaElement>) => {
Expand Down Expand Up @@ -75,6 +76,7 @@ const TextArea = forwardRef(
id={id}
maxLength={typeof maxLength === "number" && !allowExceedingMaxLength ? maxLength : undefined}
ref={ref}
value={value}
disabled={disabled}
readOnly={readOnly}
required={required}
Expand Down

0 comments on commit 6730d1c

Please sign in to comment.