Skip to content

Commit

Permalink
Remove useless memo
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Jun 1, 2021
1 parent 07b2f49 commit 44dab14
Showing 1 changed file with 44 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,48 +38,55 @@ interface RowProps {
showDeleteButton?: boolean;
}

const Row: FunctionComponent<RowProps> = React.memo(
({ index, value, onChange, onDelete, onBlur, autoFocus, isDisabled, showDeleteButton }) => {
const onDeleteHandler = useCallback(() => {
onDelete(index);
}, [onDelete, index]);
const Row: FunctionComponent<RowProps> = ({
index,
value,
onChange,
onDelete,
onBlur,
autoFocus,
isDisabled,
showDeleteButton,
}) => {
const onDeleteHandler = useCallback(() => {
onDelete(index);
}, [onDelete, index]);

const onChangeHandler = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
onChange(index, e.target.value);
},
[onChange, index]
);
const onChangeHandler = useCallback(
(e: ChangeEvent<HTMLInputElement>) => {
onChange(index, e.target.value);
},
[onChange, index]
);

return (
<EuiFlexGroup alignItems="center" gutterSize="none" responsive={false}>
<EuiFlexItem>
<EuiFieldText
fullWidth
value={value}
onChange={onChangeHandler}
autoFocus={autoFocus}
return (
<EuiFlexGroup alignItems="center" gutterSize="none" responsive={false}>
<EuiFlexItem>
<EuiFieldText
fullWidth
value={value}
onChange={onChangeHandler}
autoFocus={autoFocus}
disabled={isDisabled}
onBlur={onBlur}
/>
</EuiFlexItem>
{showDeleteButton && (
<EuiFlexItem grow={false}>
<EuiButtonIcon
color="text"
onClick={onDeleteHandler}
iconType="cross"
disabled={isDisabled}
onBlur={onBlur}
aria-label={i18n.translate('xpack.fleet.multiTextInput.deleteRowButton', {
defaultMessage: 'Delete row',
})}
/>
</EuiFlexItem>
{showDeleteButton && (
<EuiFlexItem grow={false}>
<EuiButtonIcon
color="text"
onClick={onDeleteHandler}
iconType="cross"
disabled={isDisabled}
aria-label={i18n.translate('xpack.fleet.multiTextInput.deleteRowButton', {
defaultMessage: 'Delete row',
})}
/>
</EuiFlexItem>
)}
</EuiFlexGroup>
);
}
);
)}
</EuiFlexGroup>
);
};

function defaultValue(value: string[]) {
return value.length > 0 ? value : [''];
Expand Down

0 comments on commit 44dab14

Please sign in to comment.