1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 14:34:19 +00:00
pds-2021-g2-nest/nest_frontend/hooks/useRepositoryViewer.js

15 lines
409 B
JavaScript
Raw Normal View History

2021-05-21 14:37:30 +00:00
import { useContext } from "react"
import ContextRepositoryViewer from "../contexts/ContextRepositoryViewer"
/**
2021-05-22 02:44:08 +00:00
* Hook to quickly use {@link ContextRepositoryViewer}.
2021-05-21 14:37:30 +00:00
*/
export default function useRepositoryViewer() {
2021-05-21 14:37:30 +00:00
const context = useContext(ContextRepositoryViewer)
if(!context) {
throw new Error("This component must be placed inside a RepositoryViewer.")
}
return context
2021-05-22 02:44:08 +00:00
}