Higher Order Components (HOC) React

Higher Order Components (HOC) React


const UpdatedComponent = (Original Component) => {
    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



Source link
lol

By stp2y

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.