brilliant-orangeB
Refine3y ago
7 replies
brilliant-orange

To be required to enter a value in a dynamically generated textField?

{Object.entries(itemsState).map(([key, value], index) => (
        <Box key={index} sx={{display: "flex", alignItems: "center", marginBottom: 1}}>
          <TextField          
            required={true}
            label={`${index + 1}회차 이상`}
            variant="outlined"
            size="small"
            sx={{marginBottom: 1}}
            value={value || ''}
            onChange={(e) => {
              setItemsState({
                ...itemsState,
                [key]: parseInt(e.target.value),
              });
            }}
          />
          <Typography variant="h6" sx={{marginLeft: 1}}>%</Typography>
        </Box>
      ))}
Was this page helpful?