Skip to content

Commit

Permalink
wrap handleChange with useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
fdelemarre committed Jul 10, 2024
1 parent 10bb633 commit c539623
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/webapp/components/table/Cell.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -16,10 +16,13 @@ type CellProps = {
export const Cell: React.FC<CellProps> = React.memo(
({ value, rowIndex, column, onChange = noop }) => {
const [selectorValue, setSelectorValue] = React.useState<string>(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":
Expand Down

0 comments on commit c539623

Please sign in to comment.