Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save balazimichal/2874acd89d6a65f5e3e5a19af68a2953 to your computer and use it in GitHub Desktop.
Save balazimichal/2874acd89d6a65f5e3e5a19af68a2953 to your computer and use it in GitHub Desktop.
import React from 'react'
import ReactDOM from 'react-dom'
const Info = (props) => (
<div>
<h1>Info</h1>
<p>The info is: {props.info}</p>
</div>
);
const requireAuthentication = (WrappedComponent) => {
return(props) => (
<div>
{props.isAuthenticated ? <WrappedComponent {...props} /> : <p>Please log in</p>}
</div>
)
}
const AuthInfo = requireAuthentication(Info);
ReactDOM.render(<AuthInfo isAuthenticated={false} info="secret" />, document.getElementById('root'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment