Created
April 2, 2020 03:14
-
-
Save jsmanifest/f52380324f8a68ba417163026e2f70c8 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, render, ...rest }) { | |
if (isAuthed(token)) { | |
return render({ authenticated: true }) | |
} | |
return render({ 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" | |
render={({ authenticated }) => ( | |
<DeactivatorInput disabled={!authenticated} /> | |
)} | |
/> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment