score:1

Accepted answer
import React, { Component } from "react";

export default class StyledMenuItem extends Component {
  render() {
    const { component, ...rest } = this.props; // <-- destructure and pass on the rest

    let WrapperComponent = component;
    if (WrapperComponent === undefined) {
      WrapperComponent = React.Fragment;
    }

    return <WrapperComponent {...rest}>{this.props.children}</WrapperComponent>;
  }
}

Related Query

More Query from same tag