Create generic type interface but cannot useState

36 views Asked by At

I have create generic type interface which extends StandardTextFieldProps

interface CustomAdvancedProps<T> extends StandardTextFieldProps {
  props: StandardTextFieldProps;
  onRowSelected: (value: T) => void;
  endPoint: string;
  columns: MRT_ColumnDef<any>[];
}

When function to implement this

function AdvanceTextField<T>({ props, columns, endPoint }: CustomAdvancedProps<T>) {
  const [setTestRow, testRow] = useState<T | null>();

  const modalOnClose = (value: T) => {
    console.log(`Select row: ${value}`);
    if (value != null && value !== undefined) {
      setTestRow(value);
    }
  };

I've got error on setTestRow(value);, it said This expression is not callable. Type '{}' has no call signatures.ts(2349) , Cannot invoke an object which is possibly 'null' or 'undefined'.ts(2723)

can I know how to fix it ?

0

There are 0 answers