Last active
May 15, 2019 18:20
-
-
Save benbayard/7b65ba611b0073eeb66de4f3dec5e344 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 { Forbidden, Router, Route } from 'react-express' | |
function App() { | |
return ( | |
<Router> | |
<Route path="/api"> | |
<Route path="/todos"> | |
<Route path="/:id">{({id}) => <FetchTodo id={id} />}</Route> | |
</Route> | |
</Route> | |
</Router> | |
) | |
} | |
const FetchTodo = ({id}) => { | |
const currentUser = useCurrentUser() | |
const permissions = usePermissions(currentUser) | |
if (!permissions.canRead(Todo, id)) { | |
return <Forbidden /> | |
} | |
return Todo.getById(id, currentUser) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment