Chap05 -> Declaring routes -> Creating a component containing routes

Chap05
Jason Zhu 2022-03-29 15:52:21 +11:00
parent 7c3215867f
commit fbc2541230
1 changed files with 21 additions and 17 deletions

View File

@ -2,29 +2,33 @@
import { css } from '@emotion/react';
import React from 'react';
import { Header } from './Header';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { HomePage } from './HomePage';
import { fontFamily, fontSize, gray2 } from './Styles';
import { AskPage } from './AskPage';
import { SearchPage } from './SearchPage';
import { SignInPage } from './SignInPage';
function App() {
return (
<div
css={css`
font-family: ${fontFamily};
font-size: ${fontSize};
color: ${gray2};
`}
>
<Header />
<HomePage />
</div>
<BrowserRouter>
<div
css={css`
font-family: ${fontFamily};
font-size: ${fontSize};
color: ${gray2};
`}
>
<Routes>
<Route path="" element={<HomePage />} />
<Route path="search" element={<SearchPage />} />
<Route path="ask" element={<AskPage />} />
<Route path="signin" element={<SignInPage />} />
</Routes>
</div>
</BrowserRouter>
);
}
class ProblemComponent extends React.Component {
render() {
return <div ref="div" />;
}
}
export default App;