Skip to content

Instantly share code, notes, and snippets.

@benbayard
Last active May 15, 2019 18:20
Show Gist options
  • Save benbayard/7b65ba611b0073eeb66de4f3dec5e344 to your computer and use it in GitHub Desktop.
Save benbayard/7b65ba611b0073eeb66de4f3dec5e344 to your computer and use it in GitHub Desktop.
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