Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Created April 2, 2020 03:14
Show Gist options
  • Save jsmanifest/f52380324f8a68ba417163026e2f70c8 to your computer and use it in GitHub Desktop.
Save jsmanifest/f52380324f8a68ba417163026e2f70c8 to your computer and use it in GitHub Desktop.
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