【发布时间】:2020-09-05 10:44:28
【问题描述】:
我已经制作了这个组件
const AutocompleteAdapter = ({ input, ...rest }) => (
<Autocomplete
{...input}
{...rest}
forcePopupIcon={false}
renderInput={params => <TextField {...params} {...input} {...rest} />}
/>
);
并尝试将其呈现在
<Field
required
name="coach"
label="Coach"
type="text"
placeholder="Enter Coach"
helperText="coach's email"
validate={composeValidators(required, email)}
className={classes.field}
options={mockEmails}
getOptionLabel={option => option}
component={AutocompleteAdapter}
/>
我的 mockEmails 列表属于这种类型 --> const mockEmails = ['name@gmail.com', 'name2@gmail.com']
列表在自动完成字段下呈现,但当我输入它时不会过滤结果,如果我选择列表中的一封邮件,我会收到此错误
Material-UI:getOptionLabel 的 useAutocomplete 方法无法正确处理选项。
该组件需要一个字符串,但接收到的数字。
对于输入选项:0,getOptionLabel 返回:0。
【问题讨论】:
标签: javascript reactjs debugging material-ui react-final-form