Reactjs 替代反应组件中的内部元素属性
我有一个React组件,它由其他组件组成,并使用语义ui React。它看起来像:Reactjs 替代反应组件中的内部元素属性,reactjs,semantic-ui-react,Reactjs,Semantic Ui React,我有一个React组件,它由其他组件组成,并使用语义ui React。它看起来像: export const RadioGroup = (props) => { const { value, options, label, onChange, margin, widths, ...baseProps } = props return ( <InlineFormGroup margin={margin} widths={widths}> {/* esl
export const RadioGroup = (props) => {
const { value, options, label, onChange, margin, widths, ...baseProps } = props
return (
<InlineFormGroup margin={margin} widths={widths}>
{/* eslint-disable-next-line jsx-a11y/label-has-for */}
{label && <label>{label}</label>}
{options.map(option =>
<BaseSemanticInput
...
里面有很多我展示的东西。。。。我想要的是另一个组件RadioGroupVertical,它与上面显示的RadioGroup几乎相同,只是它应该在InlineFormGroup上具有group属性。我不想复制粘贴大型组件来进行如此小的编辑,但不确定如何进行这样的属性修改。不确定我是否完全理解,但:
let otherProps = {};
if(baseProps && baseProps.group) {
otherProps.group = baseProps.group;
}
<InlineFormGroup margin={margin} widths={widths} {...otherProps}>