我不知道如何将道具传递给Box组件覆盖。
我需要按照position=的要求传递InputAdornment的“end”,但是在文档中找不到方法。
全组分
<Select
value={value}
onChange={handleChange}
input={
<OutlinedInput
endAdornment={
photoRequired && (
<Box component={InputAdornment} position="end" pr={3}>
{required && <Gallery />}
<Gallery />
</Box>
)
}
/>
}
>
{choices.map((choice, i) => (
<MenuItem key={i} value={i + 1}>
{choice}
</MenuItem>
))}
</Select>
我是错误的,试图通过上述方式,因为它不是预期的盒子。
Warning: Failed prop type: The prop `position` is marked as required in `ForwardRef(InputAdornment)`, but its value is `undefined`.```
发布于 2021-12-23 13:42:25
尝试创建使用该位置的自己的InputAdornment
组件,如:
const EndInputAdornment = () => {
return <InputAdornment position="end"/>
};
然后,可以将该组件用于Box
。
<Box component={EndInputAdornment} pr={3}>
...
或者如果您不想创建一个单独的组件:
<Box component={<InputAdornment position="end"/>} pr={3}>
应起作用
https://stackoverflow.com/questions/70462858
复制相似问题