How to create props proxy for HOC component?

Technology CommunityCategory: ReactHow to create props proxy for HOC component?
VietMX Staff asked 3 years ago

You can add/edit props passed to the Component as a props proxy as below

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} />
    }
  }
}