Created
July 21, 2018 06:33
-
-
Save balazimichal/2874acd89d6a65f5e3e5a19af68a2953 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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