Chap05 -> Using route parameters -> Adding the question page route (Finished)

master
Jason Zhu 2022-03-29 16:33:58 +11:00
parent b18e0588b5
commit 8e13f18a03
2 changed files with 18 additions and 4 deletions

View File

@ -1,8 +1,9 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { gray2, gray3 } from './Styles';
import { Link } from 'react-router-dom';
import React from 'react';
import { gray2, gray3 } from './Styles';
import { QuestionData } from './QuestionsData';
interface Props {
@ -17,8 +18,16 @@ export const Question = ({ data, showContent }: Props) => (
padding: 10px 0px;
font-size: 19px;
`}
>
<Link
css={css`
text-decoration: none;
color: ${gray2};
`}
to={`/questions/${data.questionId}`}
>
{data.title}
</Link>
</div>
{showContent && (
<div

View File

@ -1,4 +1,9 @@
import React from 'react';
import { useParams } from 'react-router-dom';
import { Page } from './Page';
export const QuestionPage = () => <Page>Question Page</Page>;
export const QuestionPage = () => {
const { questionId } = useParams();
return <Page>Question Page {questionId}</Page>;
};