Last active
September 24, 2019 20:36
-
-
Save adamjarling/a354755f5597ded173e83b10aaf68301 to your computer and use it in GitHub Desktop.
An example React component which uses React Router's match object to grab a url parameter
This file contains 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 { withRouter } from "react-router"; | |
import ScreenHeader from "../../components/UI/ScreenHeader"; | |
import Error from "../../components/UI/Error"; | |
import Loading from "../../components/UI/Loading"; | |
import { useQuery } from "@apollo/react-hooks"; | |
import { GET_PROJECT } from "../../components/Project/project.query"; | |
const ScreensProject = ({ match }) => { | |
const { id } = match.params; | |
const { loading, error, data } = useQuery(GET_PROJECT, { | |
variables: { projectId: id } | |
}); | |
if (loading) return <Loading />; | |
if (error) return <Error error={error} />; | |
return ( | |
<div> | |
{data.project && ( | |
<> | |
<ScreenHeader | |
title={data.project.title} | |
description="The following is a list of all active Ingest Sheets for a project" | |
/> | |
... | |
</> | |
)} | |
</div> | |
); | |
}; | |
export default withRouter(ScreensProject); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment