Skip to content

Commit

Permalink
Code Review fixes: turn ternary into if/else block; onChange fn fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nighto committed Nov 14, 2024
1 parent 2c94f8e commit 108c636
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ export default {
render: (args) => {
const [selectedColors, setSelectedColors] = React.useState<Array<Color>>([]);
const handleCheckboxChange = (color: Color) => {
selectedColors.includes(color) ?
setSelectedColors(selectedColors.filter(c => c !== color)) :
if (selectedColors.includes(color)) {
setSelectedColors(selectedColors.filter(c => c !== color));
} else {
setSelectedColors([...selectedColors, color]);
}
};
return (
<CheckboxGroup {...args}>
Expand All @@ -37,7 +39,7 @@ export default {
key={color}
label={color}
checked={selectedColors.includes(color)}
onChange={() => handleCheckboxChange(color as Color)}
onChange={() => { handleCheckboxChange(color as Color); }}
/>
)}
</CheckboxGroup>
Expand Down

0 comments on commit 108c636

Please sign in to comment.