InterviewHubPRO
Section Overview
Q366

Question 366 of 445

Part 11: Legacy Architecture, Migration Patterns & Historical Internals (354 - 445)

82%
React & Modern Frontend (445 Qs)•Part 11: Legacy Architecture, Migration Patterns & Historical Internals (354 - 445)

How to create props proxy for HOC component?

You can add/edit props passed to the component using props proxy pattern like this:

jsx
    function HOC(WrappedComponent) {
      return class Test extends Component {
        render() {
          const newProps = {
            title: "New Header",
            footer: false,
            showFeatureX: false,
            showFeatureY: true,
          };

          return <WrappedComponent {...this.props} {...newProps} />;
        }
      };
    }