useForm은 쉽게 form을 관리하기 위한 훅이다.
: gives you access to the history instance that you may use to navigate.
: returns the location object that represents the current URL
: URL 매개변수의 키/값 쌍의 개체를 반환
import React from "react";
import ReactDOM from "react-dom";
import {
BrowserRouter as Router,
Switch,
Route,
useParams
} from "react-router-dom";
function BlogPost() {
let { slug } = useParams();
return <div>Now showing post {slug}</div>;
}
ReactDOM.render(
<Router>
<Switch>
<Route exact path="/">
<HomePage />
</Route>
<Route path="/blog/:slug">
<BlogPost />
</Route>
</Switch>
</Router>,
node
);
https://v5.reactrouter.com/web/api/Hooks/useparams
: 실제로 렌더링하지 않고 일치하는 url에 엑세스. 해당하는 url맞는지 판별
페이지 내 탭 메뉴 접근에 활용.
https://v5.reactrouter.com/web/api/Hooks/useroutematch
React Router hook 관련 Doc: https://v5.reactrouter.com/web/api/Hooks