Chap05 -> Using route parameters -> Adding the question page route (Finished)
This commit is contained in:
parent
b18e0588b5
commit
8e13f18a03
@ -1,8 +1,9 @@
|
|||||||
/** @jsxImportSource @emotion/react */
|
/** @jsxImportSource @emotion/react */
|
||||||
import { css } from '@emotion/react';
|
import { css } from '@emotion/react';
|
||||||
import { gray2, gray3 } from './Styles';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { gray2, gray3 } from './Styles';
|
||||||
import { QuestionData } from './QuestionsData';
|
import { QuestionData } from './QuestionsData';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -18,7 +19,15 @@ export const Question = ({ data, showContent }: Props) => (
|
|||||||
font-size: 19px;
|
font-size: 19px;
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
{data.title}
|
<Link
|
||||||
|
css={css`
|
||||||
|
text-decoration: none;
|
||||||
|
color: ${gray2};
|
||||||
|
`}
|
||||||
|
to={`/questions/${data.questionId}`}
|
||||||
|
>
|
||||||
|
{data.title}
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
{showContent && (
|
{showContent && (
|
||||||
<div
|
<div
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { Page } from './Page';
|
import { Page } from './Page';
|
||||||
|
|
||||||
export const QuestionPage = () => <Page>Question Page</Page>;
|
export const QuestionPage = () => {
|
||||||
|
const { questionId } = useParams();
|
||||||
|
return <Page>Question Page {questionId}</Page>;
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user