Created
April 2, 2020 03:14
-
-
Save jsmanifest/ae91611349bdf7f889a724b8471b820c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function AuthValidator({ token, children, ...rest }) { | |
if (isAuthed(token)) { | |
return children({ authenticated: true }) | |
} | |
return children({ authenticated: false }) | |
} | |
const DeactivatorInput = ({ style, ...rest }) => ( | |
<input | |
{...rest} | |
style={{ | |
minWidth: 200, | |
border: '1px solid rgba(0, 0, 0, 0.5)', | |
borderRadius: 4, | |
padding: '6px 12px', | |
...style, | |
}} | |
placeholder="Search a user to deactivate" | |
/> | |
) | |
function App() { | |
return ( | |
<div> | |
<AuthValidator token="abc123"> | |
{({ authenticated }) => <DeactivatorInput disabled={!authenticated} />} | |
</AuthValidator> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment