<Switch>
<Route path="/" ..... />
</Switch>
<Routes>
<Route path="/" ..... />
</Routes>
<Route path="/" exact component={HomePage} />
<Route path="/login" exact>
<LoginPage />
</Route>
<Route path="/" exact element={<HomePage />} />
<Route path="/login" exact element={<LoginPage />} />
<Route path="/users/:username" component={UsersPage} />
<Route path="/users/:username/*" element={<UsersPage />} />
<NavLink to="/messages" style={{ color: "blue"}} activeStyle={{ color: "green"}}>
Messages
</NavLink>
<NavLink to="/messages" className="nav-link" activeClassName="activated">
Messages
</NavLink>
<NavLink to="/messages" style={({ isActive }) => ({ color: isActive ? 'green' : 'blue' })}>
Messages
</NavLink>
<NavLink to="/messages" className={({ isActive }) => "nav-link" + (isActive ? " activated" : "") }>
Messages
</NavLink>
import React from "react";
import { Link, useLocation } from "react-router-dom";
import styled from "styled-components";
const HeaderWrapper = styled("header")`
margin-bottom: 30px;
`;
const List = styled("ul")`
display: flex;
`;
const Item = styled("li")`
margin-right: 20px;
text-transform: uppercase;
font-weight: 600;
color: ${(props) => (props.selected ? "white" : "black")};
background-color: ${(props) => (props.selected ? "#f1c40f" : "white")};
`;
const Header = () => {
const { pathname } = useLocation();
return (
<HeaderWrapper>
{/* header ํ๊ทธ */}
<List>
{/* ul ํ๊ทธ */}
<Item selected={pathname.startsWith("/web")}>
{/* li ํ๊ทธ */}
<Link to="/web">Go to Web</Link>
</Item>
<Item selected={pathname === "/design"}>
<Link to="/design">Go to Design</Link>
</Item>
<Item selected={pathname === "/server"}>
<Link to="/server">Go to Server</Link>
</Item>
</List>
</HeaderWrapper>
);
};
export default Header;
// WebPost.js
import React from "react";
import { useParams } from "react-router";
const WebPost = () => {
const { id } = useParams();
return <div>#{id}๋ฒ์งธ ํฌ์คํธ</div>;
};
export default WebPost;
const history = useHistory();
history.push('/');
history.goback();
history.go(-2);
history.push(`/user/${user._id}`);
const navigate = useNavigate();
navigate('/');
navigate(-1);
navigate(-2);
navigate(`/user/${user._id}`);
<Switch>
<Route path="/" ..... />
</Switch>
<Routes>
<Route path="/" ..... />
</Routes>
<Route path="/" exact component={HomePage} />
<Route path="/login" exact>
<LoginPage />
</Route>
<Route path="/" exact element={<HomePage />} />
<Route path="/login" exact element={<LoginPage />} />
<Route path="/users/:username" component={UsersPage} />
<Route path="/users/:username/*" element={<UsersPage />} />
<NavLink to="/messages" style={{ color: "blue"}} activeStyle={{ color: "green"}}>
Messages
</NavLink>
<NavLink to="/messages" className="nav-link" activeClassName="activated">
Messages
</NavLink>
<NavLink to="/messages" style={({ isActive }) => ({ color: isActive ? 'green' : 'blue' })}>
Messages
</NavLink>
<NavLink to="/messages" className={({ isActive }) => "nav-link" + (isActive ? " activated" : "") }>
Messages
</NavLink>
import React from "react";
import { Link, useLocation } from "react-router-dom";
import styled from "styled-components";
const HeaderWrapper = styled("header")`
margin-bottom: 30px;
`;
const List = styled("ul")`
display: flex;
`;
const Item = styled("li")`
margin-right: 20px;
text-transform: uppercase;
font-weight: 600;
color: ${(props) => (props.selected ? "white" : "black")};
background-color: ${(props) => (props.selected ? "#f1c40f" : "white")};
`;
const Header = () => {
const { pathname } = useLocation();
return (
<HeaderWrapper>
{/* header ํ๊ทธ */}
<List>
{/* ul ํ๊ทธ */}
<Item selected={pathname.startsWith("/web")}>
{/* li ํ๊ทธ */}
<Link to="/web">Go to Web</Link>
</Item>
<Item selected={pathname === "/design"}>
<Link to="/design">Go to Design</Link>
</Item>
<Item selected={pathname === "/server"}>
<Link to="/server">Go to Server</Link>
</Item>
</List>
</HeaderWrapper>
);
};
export default Header;
// WebPost.js
import React from "react";
import { useParams } from "react-router";
const WebPost = () => {
const { id } = useParams();
return <div>#{id}๋ฒ์งธ ํฌ์คํธ</div>;
};
export default WebPost;
const history = useHistory();
history.push('/');
history.goback();
history.go(-2);
history.push(`/user/${user._id}`);
const navigate = useNavigate();
navigate('/');
navigate(-1);
navigate(-2);
navigate(`/user/${user._id}`);
<Switch>
<Route path="/" ..... />
</Switch>
<Routes>
<Route path="/" ..... />
</Routes>
<Route path="/" exact component={HomePage} />
<Route path="/login" exact>
<LoginPage />
</Route>
<Route path="/" exact element={<HomePage />} />
<Route path="/login" exact element={<LoginPage />} />
<Route path="/users/:username" component={UsersPage} />
<Route path="/users/:username/*" element={<UsersPage />} />
<NavLink to="/messages" style={{ color: "blue"}} activeStyle={{ color: "green"}}>
Messages
</NavLink>
<NavLink to="/messages" className="nav-link" activeClassName="activated">
Messages
</NavLink>
<NavLink to="/messages" style={({ isActive }) => ({ color: isActive ? 'green' : 'blue' })}>
Messages
</NavLink>
<NavLink to="/messages" className={({ isActive }) => "nav-link" + (isActive ? " activated" : "") }>
Messages
</NavLink>
import React from "react";
import { Link, useLocation } from "react-router-dom";
import styled from "styled-components";
const HeaderWrapper = styled("header")`
margin-bottom: 30px;
`;
const List = styled("ul")`
display: flex;
`;
const Item = styled("li")`
margin-right: 20px;
text-transform: uppercase;
font-weight: 600;
color: ${(props) => (props.selected ? "white" : "black")};
background-color: ${(props) => (props.selected ? "#f1c40f" : "white")};
`;
const Header = () => {
const { pathname } = useLocation();
return (
<HeaderWrapper>
{/* header ํ๊ทธ */}
<List>
{/* ul ํ๊ทธ */}
<Item selected={pathname.startsWith("/web")}>
{/* li ํ๊ทธ */}
<Link to="/web">Go to Web</Link>
</Item>
<Item selected={pathname === "/design"}>
<Link to="/design">Go to Design</Link>
</Item>
<Item selected={pathname === "/server"}>
<Link to="/server">Go to Server</Link>
</Item>
</List>
</HeaderWrapper>
);
};
export default Header;
// WebPost.js
import React from "react";
import { useParams } from "react-router";
const WebPost = () => {
const { id } = useParams();
return <div>#{id}๋ฒ์งธ ํฌ์คํธ</div>;
};
export default WebPost;
const history = useHistory();
history.push('/');
history.goback();
history.go(-2);
history.push(`/user/${user._id}`);
const navigate = useNavigate();
navigate('/');
navigate(-1);
navigate(-2);
navigate(`/user/${user._id}`);
<Switch>
<Route path="/" ..... />
</Switch>
<Routes>
<Route path="/" ..... />
</Routes>
<Route path="/" exact component={HomePage} />
<Route path="/login" exact>
<LoginPage />
</Route>
<Route path="/" exact element={<HomePage />} />
<Route path="/login" exact element={<LoginPage />} />
<Route path="/users/:username" component={UsersPage} />
<Route path="/users/:username/*" element={<UsersPage />} />
<NavLink to="/messages" style={{ color: "blue"}} activeStyle={{ color: "green"}}>
Messages
</NavLink>
<NavLink to="/messages" className="nav-link" activeClassName="activated">
Messages
</NavLink>
<NavLink to="/messages" style={({ isActive }) => ({ color: isActive ? 'green' : 'blue' })}>
Messages
</NavLink>
<NavLink to="/messages" className={({ isActive }) => "nav-link" + (isActive ? " activated" : "") }>
Messages
</NavLink>
import React from "react";
import { Link, useLocation } from "react-router-dom";
import styled from "styled-components";
const HeaderWrapper = styled("header")`
margin-bottom: 30px;
`;
const List = styled("ul")`
display: flex;
`;
const Item = styled("li")`
margin-right: 20px;
text-transform: uppercase;
font-weight: 600;
color: ${(props) => (props.selected ? "white" : "black")};
background-color: ${(props) => (props.selected ? "#f1c40f" : "white")};
`;
const Header = () => {
const { pathname } = useLocation();
return (
<HeaderWrapper>
{/* header ํ๊ทธ */}
<List>
{/* ul ํ๊ทธ */}
<Item selected={pathname.startsWith("/web")}>
{/* li ํ๊ทธ */}
<Link to="/web">Go to Web</Link>
</Item>
<Item selected={pathname === "/design"}>
<Link to="/design">Go to Design</Link>
</Item>
<Item selected={pathname === "/server"}>
<Link to="/server">Go to Server</Link>
</Item>
</List>
</HeaderWrapper>
);
};
export default Header;
// WebPost.js
import React from "react";
import { useParams } from "react-router";
const WebPost = () => {
const { id } = useParams();
return <div>#{id}๋ฒ์งธ ํฌ์คํธ</div>;
};
export default WebPost;
const history = useHistory();
history.push('/');
history.goback();
history.go(-2);
history.push(`/user/${user._id}`);
const navigate = useNavigate();
navigate('/');
navigate(-1);
navigate(-2);
navigate(`/user/${user._id}`);
<Switch>
<Route path="/" ..... />
</Switch>
<Routes>
<Route path="/" ..... />
</Routes>
<Route path="/" exact component={HomePage} />
<Route path="/login" exact>
<LoginPage />
</Route>
<Route path="/" exact element={<HomePage />} />
<Route path="/login" exact element={<LoginPage />} />
<Route path="/users/:username" component={UsersPage} />
<Route path="/users/:username/*" element={<UsersPage />} />
<NavLink to="/messages" style={{ color: "blue"}} activeStyle={{ color: "green"}}>
Messages
</NavLink>
<NavLink to="/messages" className="nav-link" activeClassName="activated">
Messages
</NavLink>
<NavLink to="/messages" style={({ isActive }) => ({ color: isActive ? 'green' : 'blue' })}>
Messages
</NavLink>
<NavLink to="/messages" className={({ isActive }) => "nav-link" + (isActive ? " activated" : "") }>
Messages
</NavLink>
import React from "react";
import { Link, useLocation } from "react-router-dom";
import styled from "styled-components";
const HeaderWrapper = styled("header")`
margin-bottom: 30px;
`;
const List = styled("ul")`
display: flex;
`;
const Item = styled("li")`
margin-right: 20px;
text-transform: uppercase;
font-weight: 600;
color: ${(props) => (props.selected ? "white" : "black")};
background-color: ${(props) => (props.selected ? "#f1c40f" : "white")};
`;
const Header = () => {
const { pathname } = useLocation();
return (
<HeaderWrapper>
{/* header ํ๊ทธ */}
<List>
{/* ul ํ๊ทธ */}
<Item selected={pathname.startsWith("/web")}>
{/* li ํ๊ทธ */}
<Link to="/web">Go to Web</Link>
</Item>
<Item selected={pathname === "/design"}>
<Link to="/design">Go to Design</Link>
</Item>
<Item selected={pathname === "/server"}>
<Link to="/server">Go to Server</Link>
</Item>
</List>
</HeaderWrapper>
);
};
export default Header;
// WebPost.js
import React from "react";
import { useParams } from "react-router";
const WebPost = () => {
const { id } = useParams();
return <div>#{id}๋ฒ์งธ ํฌ์คํธ</div>;
};
export default WebPost;
const history = useHistory();
history.push('/');
history.goback();
history.go(-2);
history.push(`/user/${user._id}`);
const navigate = useNavigate();
navigate('/');
navigate(-1);
navigate(-2);
navigate(`/user/${user._id}`);
<Switch>
<Route path="/" ..... />
</Switch>
<Routes>
<Route path="/" ..... />
</Routes>
<Route path="/" exact component={HomePage} />
<Route path="/login" exact>
<LoginPage />
</Route>
<Route path="/" exact element={<HomePage />} />
<Route path="/login" exact element={<LoginPage />} />
<Route path="/users/:username" component={UsersPage} />
<Route path="/users/:username/*" element={<UsersPage />} />