Skip to content

Commit

Permalink
refactor(Tile): use hoisted functions instead of expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
emyarod committed Apr 5, 2021
1 parent 11bd374 commit 727b379
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/react/src/components/Tile/Tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,29 +223,29 @@ export function SelectableTile(props) {
);

// TODO: rename to handleClick when handleClick prop is deprecated
const handleOnClick = (evt) => {
function handleOnClick(evt) {
evt.preventDefault();
evt.persist();
setIsSelected(!isSelected);
clickHandler(evt);
onChange(evt);
};
}

// TODO: rename to handleKeyDown when handleKeyDown prop is deprecated
const handleOnKeyDown = (evt) => {
function handleOnKeyDown(evt) {
evt.persist();
if (matches(evt, [keys.Enter, keys.Space])) {
evt.preventDefault();
setIsSelected(!isSelected);
onChange(evt);
}
keyDownHandler(evt);
};
}

const handleChange = (event) => {
function handleChange(event) {
setIsSelected(event.target.checked);
onChange(event);
};
}

useEffect(() => {
setIsSelected(selected);
Expand Down

0 comments on commit 727b379

Please sign in to comment.