Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Use memoization

dominik-zeglen977165059efe
diff --git a/saleor/static/dashboard-next/components/Checkbox/Checkbox.tsx b/saleor/static/dashboard-next/components/Checkbox/Checkbox.tsx
index 63dd179890..31c23d9cef 100644
--- a/saleor/static/dashboard-next/components/Checkbox/Checkbox.tsx
+++ b/saleor/static/dashboard-next/components/Checkbox/Checkbox.tsx
@@ -91,20 +91,23 @@ const Checkbox = withStyles(styles, { name: "Checkbox" })(
...props
}: CheckboxProps & WithStyles<typeof styles>) => {
const inputRef = React.useRef<HTMLInputElement>(null);
+ const handleClick = React.useCallback(
+ disableClickPropagation
+ ? event => {
+ event.stopPropagation();
+ inputRef.current.click();
+ }
+ : () => inputRef.current.click(),
+ []
+ );
+
return (
<ButtonBase
{...props}
centerRipple
className={classNames(classes.root, className)}
disabled={disabled}
- onClick={
- disableClickPropagation
- ? event => {
- event.stopPropagation();
- inputRef.current.click();
- }
- : () => inputRef.current.click()
- }
+ onClick={handleClick}
>
<input
className={classNames(classes.box, {