简体   繁体   中英

getting error warning in MUI TextField component with select

getting error in console MUI: children must be passed when using the TextField component with select .

               <TextField
                select
                id="outlined-basic"
                label="User Name"
                name="user"
                size="small"
                {...teamForm.getFieldProps("user")}
                error={teamForm.touched.user && teamForm.errors.user}
                helpertext={teamForm.touched.user && teamForm.errors.user}
              >
                {list?.map((option) => (
                  <MenuItem key={option.username} value={option.name}>
                    {option.name}
                  </MenuItem>
                ))}
              </TextField>

Adding some other content when no list provided might help for this:

 <TextField select id="outlined-basic" label="User Name" name="user" size="small" {...teamForm.getFieldProps("user")} error={teamForm.touched.user && teamForm.errors.user} helpertext={teamForm.touched.user && teamForm.errors.user} > {list? list.map((option) => ( <MenuItem key={option.username} value={option.name}> {option.name} </MenuItem> )): <div></div>} </TextField>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM