HimanshuP90 / React-Redux-Basic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HOC: A higher order component in React is a pattern used to share common functionality between components without repeating code. A HOC function takes a component as an argument and returns a component. It transforms a component into another component and adds additional data or functionality

const NewComponent = (BaseComponent) => {
  // ... create new component from old one and update
    return UpdatedComponent
}



const higherOrderComponent = (WrappedComponent) => {
    class HOC extends React.Component {
        render(){
            return <WrappedComponent />
        }
    }
    return HOC;
};

//We can invoke the HOC as follows:
const SimpleHOC = higherOrderComponent(MyComponent);

About


Languages

Language:JavaScript 83.4%Language:HTML 9.1%Language:CSS 7.5%