react tutorial - reactjs tutorial - Higher Order Component that checks for authentication - react - reactjs - react native
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():
We then just use this Higher Order Component in our components that should be hidden from anonymous users:
This example is described in more detail here.