Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Commit

Permalink
perf(input): remove unnecessary label null check
Browse files Browse the repository at this point in the history
  • Loading branch information
wtchnm committed Jul 26, 2020
1 parent feb8564 commit b23da69
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@ interface Props {
placeholder?: string;

onFocus?(event: React.FocusEvent<HTMLInputElement>): void;
onMouseDown?(event: React.MouseEvent<HTMLInputElement, MouseEvent>): void;
onBlur?(event: React.FocusEvent<HTMLInputElement>): void;
onMouseDown?(event: React.MouseEvent<HTMLInputElement, MouseEvent>): void;
onKeyDown?(event: React.KeyboardEvent<HTMLInputElement>): void;
}

function Input({
value,
onChange,

label,
placeholder,

onFocus,
onMouseDown,
onBlur,
onMouseDown,
onKeyDown,
}: Props): ReactElement {
const componentId = useMemo(() => `Input-${nanoid()}`, []);

return (
<div className="flex flex-col">
{label && (
<label
className="text-gray-700 mb-1 pr-4 leading-normal"
htmlFor={componentId}
>
{label}
</label>
)}
<label
htmlFor={componentId}
className="text-gray-700 mb-1 pr-4 leading-normal"
>
{label}
</label>
<input
type="text"
id={componentId}
value={value}
onChange={onChange}
className="appearance-none bg-white border border-solid border-gray-400 rounded w-full py-2 px-3 focus:outline-none focus:shadow-outline focus:border-blue-400 leading-normal box-border text-base placeholder-gray-500"
id={componentId}
type="text"
placeholder={placeholder}
className="appearance-none bg-white border border-solid border-gray-400 rounded w-full py-2 px-3 focus:outline-none focus:shadow-outline focus:border-blue-400 leading-normal box-border text-base placeholder-gray-500"
onFocus={onFocus}
onMouseDown={onMouseDown}
onBlur={onBlur}
onMouseDown={onMouseDown}
onKeyDown={onKeyDown}
/>
</div>
Expand Down

0 comments on commit b23da69

Please sign in to comment.