我正在使用 React 创建一个新表单,其中一个输入是 Material UI 输入。表单效果很好,但Missing name at
即使我在选择输入和 Material UI 创建的隐藏输入上都输入了名称,但在加载表单时控制台会显示警告。
<FormControl variant="filled" className={classes.formControl} style={{ width: '100%' }}>
<InputLabel id="dog-breed-label">Dog Breed</InputLabel>
<Select
label="Dog Breed"
labelId="dog-breed-label"
name="dogBreed"
value={defaultDog.dogBreed}
onChange={event => setBankAccount({ ...dogBreed, dogBreed: event.target.value })}
inputRef={register({ required: true })}
variant="filled"
style={{ width: '100%' }}
inputProps={{ name: 'dogBreedInput' }}
inputRef={register({ required: true })}
>
<MenuItem value="CHIHUAHUA">Chihuahua</MenuItem>
<MenuItem value="LABRADOR">Labrador Retriever</MenuItem>
</Select>
</FormControl>
警告信息(截图):
Missing name at {node: input, value: undefined, focus: ƒ}focus: ƒ focus()node: inputvalue: undefined__proto__: Object
in SelectInput (created by InputBase)
in InputBase (created by WithStyles(ForwardRef(InputBase)))
in WithStyles(ForwardRef(InputBase)) (created by FilledInput)
in FilledInput (created by WithStyles(ForwardRef(FilledInput)))
in WithStyles(ForwardRef(FilledInput)) (created by Select)
in Select (created by WithStyles(ForwardRef(Select)))
in WithStyles(ForwardRef(Select)) (at modal.js:95)
in Modal (at bankInformation/index.js:146)
in Anonymous (at demographics/index.js:199)
in Anonymous (at routes/index.js:16)
我需要添加什么以避免在控制台中看到此警告?