Skip to content

Commit

Permalink
fix: make sure auto identificator gets generated
Browse files Browse the repository at this point in the history
Co-Authored-By: Andre Luiz Rabello <andre.luiz_r@hotmail.com>
  • Loading branch information
Julius Osokinas and rabelloo committed Feb 9, 2021
1 parent 9eeafef commit 6795a72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions packages/react/src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ export const Input = withRef(
}: InputProps,
ref: InputProps['ref']
): JSX.Element => {
const [autoId] = useState<string | undefined>(() =>
children ? `${idPrefix}_${++idCount}` : undefined
);
const id = externalId || autoId;
const [autoId] = useState(() => `${idPrefix}_${++idCount}`);
const id = externalId || (children ? autoId : undefined);

return (
<FieldLabelWrapper id={id}>
Expand Down
6 changes: 2 additions & 4 deletions packages/react/src/components/textarea/textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ export const Textarea = withRef(
}: TextareaProps,
ref: TextareaProps['ref']
): JSX.Element => {
const [autoId] = useState<string | undefined>(() =>
children ? `${idPrefix}_${++idCount}` : undefined
);
const id = externalId || autoId;
const [autoId] = useState(() => `${idPrefix}_${++idCount}`);
const id = externalId || (children ? autoId : undefined);

return (
<FieldLabelWrapper id={id}>
Expand Down

0 comments on commit 6795a72

Please sign in to comment.