From c539623b7ceacde2db653ae76c2730adeb53740a Mon Sep 17 00:00:00 2001 From: fdelemarre Date: Wed, 10 Jul 2024 09:59:18 +0200 Subject: [PATCH] wrap handleChange with useCallback --- src/webapp/components/table/Cell.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/webapp/components/table/Cell.tsx b/src/webapp/components/table/Cell.tsx index 8573539b..eb96228c 100644 --- a/src/webapp/components/table/Cell.tsx +++ b/src/webapp/components/table/Cell.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useCallback } from "react"; import { TableCell, Link } from "@material-ui/core"; import styled from "styled-components"; import { Selector } from "../selector/Selector"; @@ -16,10 +16,13 @@ type CellProps = { export const Cell: React.FC = React.memo( ({ value, rowIndex, column, onChange = noop }) => { const [selectorValue, setSelectorValue] = React.useState(value); - const handleChange = (value: string) => { - setSelectorValue(value); - onChange(value, rowIndex, column.value); - }; + const handleChange = useCallback( + (value: string) => { + setSelectorValue(value); + onChange(value, rowIndex, column.value); + }, + [onChange, rowIndex, column.value] + ); switch (column.type) { case "link":