| Start |
|---|
| Higher Order Component that checks for authentication Let's say we have a component that should only be displayed if the user is logged in. So we create a HOC that checks for the authentication on each render(): AuthenticatedComponent.js We then just use this Higher Order Component in our components that should be hidden from anonymous users: MyPrivateComponent.js This example is described in more detail here (opens new window). |
| Simple Higher Order Component Let's say we want to console.log each time the component mounts: hocLogger.js Use this HOC in your code: MyLoggedComponent.js RemarksHOCs are pretty often used in third party libraries. Such as the Redux connect (opens new window) function. |
Read Article
https://develop.horje.com/learn/1434/reference