Project/sendbird를 활용한 웹 채팅
[Sendbird를 활용한 웹 채팅] 4. 라우팅 & 전체 스타일
반응형
1. 라우팅
Components/Router.js
import React from "react";
import { BrowserRouter, Route, Redirect, Switch } from "react-router-dom";
import GroupChat from "../Pages/GroupChat";
import OpenChat from "../Pages/OpenChat";
import Chatting from "../Pages/Chatting";
import Login from "../Pages/Login";
import MailLogin from "../Pages/MailLogin";
const Router = () => (
<BrowserRouter>
<>
<Switch>
<Route path="/" exact component={AllChat} />
<Route path="/open" component={OpenChat} />
<Route path="/group" component={GroupChat} />
<Route path="/chatting/:url/:isopen" component={Chatting} />
<Route path="/login" component={Login} />
<Route path="/mail" component={MailLogin} />
<Redirect from="*" to="/" />
</Switch>
</>
</BrowserRouter>
);
export default Router;
2. 글로벌 스타일
Components/GlobalStyles.js
import { createGlobalStyle } from "styled-components";
import reset from "styled-reset";
const GlobalStyles = createGlobalStyle`
${reset};
a{
text-decoration:none;
color:inherit;
}
*{
box-sizing:border-box;
}
body{
margin: 0 auto;
max-width: 960px;
color: #000;
background: #fff;
}
`;
export default GlobalStyles;
3. App.js
/App.js
import React from "react";
import GlobalStyles from "./Components/GlobalStyles";
import Router from "./Components/Router";
function App() {
return (
<>
<GlobalStyles />
<Router />
</>
);
}
export default App;
4. index.js
/index.js
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById("root")
);
반응형
'Project > sendbird를 활용한 웹 채팅' 카테고리의 다른 글
[Sendbird를 활용한 웹 채팅] 6. 로그인 시행착오 (CORS, Failed to load resource: the server responed with a status of 404 (Not Found)) (0) | 2021.09.13 |
---|---|
[Sendbird를 활용한 웹 채팅] 5. 소셜 로그인 - 네이버, 카카오 (0) | 2021.09.05 |
[Sendbird를 활용한 웹 채팅] 3. 프로젝트 구조 & 패키지 설치 (0) | 2021.09.05 |
[Sendbird를 활용한 웹 채팅] 2. 주요 기능 & 대시보드 가입 (0) | 2021.09.04 |
[Sendbird를 활용한 웹 채팅] 1. 개요 (0) | 2021.08.31 |