5
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
*/
7
7
import { Table , TableBody , TableCell , TableContainer , TableHead , TableRow , Tooltip } from '@mui/material' ;
8
- import { useMemo } from 'react' ;
9
8
import { useFieldArray } from 'react-hook-form' ;
10
9
import {
11
10
LimitReductionIColumnsDef ,
@@ -19,7 +18,7 @@ interface LimitReductionsTableProps {
19
18
columnsDefinition : LimitReductionIColumnsDef [ ] ;
20
19
tableHeight : number ;
21
20
formName : string ;
22
- limits : ILimitReductionsByVoltageLevel [ ] ;
21
+ limits ? : ILimitReductionsByVoltageLevel [ ] ;
23
22
}
24
23
25
24
export function CustomVoltageLevelTable ( {
@@ -32,11 +31,6 @@ export function CustomVoltageLevelTable({
32
31
name : formName ,
33
32
} ) ;
34
33
35
- const TableRowComponent = useMemo (
36
- ( ) => ( formName === LIMIT_REDUCTIONS_FORM ? LimitReductionTableRow : CustomVoltageLevelTableRow ) ,
37
- [ formName ]
38
- ) ;
39
-
40
34
return (
41
35
< TableContainer
42
36
sx = { {
@@ -63,15 +57,23 @@ export function CustomVoltageLevelTable({
63
57
</ TableRow >
64
58
</ TableHead >
65
59
< TableBody >
66
- { rows . map ( ( row , index ) => (
67
- < TableRowComponent
68
- key = { `${ row . id } ` }
69
- columnsDefinition = { columnsDefinition }
70
- index = { index }
71
- formName = { formName }
72
- limits = { limits }
73
- />
74
- ) ) }
60
+ { rows . map ( ( row , index ) =>
61
+ formName === LIMIT_REDUCTIONS_FORM && limits ? (
62
+ < LimitReductionTableRow
63
+ key = { `${ row . id } ` }
64
+ columnsDefinition = { columnsDefinition }
65
+ index = { index }
66
+ limits = { limits }
67
+ />
68
+ ) : (
69
+ < CustomVoltageLevelTableRow
70
+ key = { `${ row . id } ` }
71
+ columnsDefinition = { columnsDefinition }
72
+ index = { index }
73
+ formName = { formName }
74
+ />
75
+ )
76
+ ) }
75
77
</ TableBody >
76
78
</ Table >
77
79
</ TableContainer >
0 commit comments