Created
April 2, 2020 03:15
-
-
Save jsmanifest/06fca25bf8564bae57141a10c7e6ac06 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
import React from 'react' | |
import ControlPanel from './ControlPanel' | |
import ControlButton from './ControlButton' | |
function AuthValidator({ token, render, ...rest }) { | |
if (isAuthed(token)) { | |
return render({ authenticated: true }) | |
} | |
return render({ authenticated: false }) | |
} | |
function App() { | |
return ( | |
<div> | |
<AuthValidator | |
render={({ authenticated }) => { | |
if (!authenticated) { | |
return null | |
} | |
return ( | |
<ControlPanel | |
authenticated={authenticated} | |
render={({ Container, controls }) => ( | |
<Container | |
render={({ width, height }) => ( | |
<div style={{ width, height }}> | |
{controls.map((options) => | |
options.render ? ( | |
<ControlButton | |
render={({ Component }) => ( | |
<Component {...options} /> | |
)} | |
/> | |
) : ( | |
<ControlButton {...options} /> | |
), | |
)} | |
</div> | |
)} | |
/> | |
)} | |
/> | |
) | |
}} | |
/> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment