Linting fixes

This commit is contained in:
Fred Carlsen
2019-02-13 01:50:06 +01:00
committed by Jacob Evans
parent 1c040bd616
commit b9a93c82d7
3 changed files with 19 additions and 27 deletions

View File

@@ -15,6 +15,7 @@ interface InputProps {
width?: InputWidth;
label: string;
type?: string;
defaultValue?: string;
errors?: ErrorProps;
isErrors?: boolean;
required?: boolean;
@@ -64,7 +65,7 @@ export const CheckBoxInput = (props: CheckBoxProps) => {
};
export const Input = React.forwardRef((props: InputProps, ref?: React.Ref<HTMLInputElement>) => {
const { name, label, type, errors } = props;
const { name, label, type, errors, defaultValue } = props;
const id = `input-${name}`;
const componentType = type === 'textarea' ? 'textarea' : 'input';
const isErrors = errors.hasOwnProperty(name) && errors[name] !== null;
@@ -73,7 +74,7 @@ export const Input = React.forwardRef((props: InputProps, ref?: React.Ref<HTMLIn
return (
<InputWrapper {...props}>
<Label htmlFor={id}>{label}</Label>
<StyledInput as={componentType} ref={ref} id={id} isErrors={isErrors} {...props} />
<StyledInput as={componentType} ref={ref} id={id} isErrors={isErrors} defaultValue={defaultValue} {...props} />
{isErrors && <Error>{errorMessage}</Error>}
</InputWrapper>
);