Skip to content

Commit

Permalink
style: extract expression for better readability
Browse files Browse the repository at this point in the history
  • Loading branch information
feclist committed Nov 12, 2024
1 parent 6730d1c commit ef2503c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const TextArea = forwardRef(
const numRows = rows || DEFAULT_ROWS[size];
const helpTextId = helpText && `${id}-help-text`;
const allowExceedingMaxLengthTextId = allowExceedingMaxLength && `${id}-allow-exceeding-max-length`;
const inErrorState = error || (maxLength && value?.length > maxLength);

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

Expand All @@ -57,7 +58,7 @@ const TextArea = forwardRef(
className={cx(
styles.textAreaWrapper,
{
[styles.error]: error || (maxLength && characterCount > maxLength),
[styles.error]: inErrorState,
[styles.success]: success,
[styles.disabled]: disabled,
[styles.readOnly]: readOnly
Expand Down

0 comments on commit ef2503c

Please sign in to comment.