DEV Community

Fatima Alam
Fatima Alam

Posted on • Updated on

Higher Order Components (HOC) React

const UpdatedComponent = (OriginalComponent) => {
    class NewComponent extends React.Component {
        constructor(){
            this.state = {
                ...
            }
        }
        render(){
            return(
                <OriginalComponent  props/>
            );
        }
    }
    return NewComponent;
};




class OGComponent extends React.Component{
    ...
    //available via (this.props..)
}

export default UpdatedComponent(OGComponent);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)