Skip to content

Commit

Permalink
fix: fix issue with input values
Browse files Browse the repository at this point in the history
Поправил value в компоненте Input. Теперь компонент не меняется с uncontrolled на controlled

#299
  • Loading branch information
kavabunga committed Jan 15, 2024
1 parent 9b52d57 commit 5612a93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/ui/input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type InputProps = {
} & React.InputHTMLAttributes<HTMLInputElement>;

const Input: React.FC<InputProps> = (props: InputProps) => {
const { inputNameSpan, error, isValid, withErrorSpan, ...inputProps } = props;
const { inputNameSpan, error, isValid, withErrorSpan, value, ...inputProps } = props;
const hasError = error && error[inputProps.name || ''];

return (
Expand All @@ -19,7 +19,7 @@ const Input: React.FC<InputProps> = (props: InputProps) => {
className={`${styles.input_type_normal} ${
hasError && !isValid ? `${styles.input_type_error}` : ''
}`}
value={inputProps.value !== undefined ? String(inputProps.value) : ''}
value={value ? String(value) : ''}
{...inputProps}
/>
{withErrorSpan && <span className={styles.spanAfter}>{hasError as string}</span>}
Expand Down

0 comments on commit 5612a93

Please sign in to comment.