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 12, 2021
1 parent 8ea3b21 commit d52f7d2
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 @@ -226,29 +226,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 d52f7d2

Please sign in to comment.