검색어
history.replaceState(stateObj, title[, url])
router.replace('/??',undefined,{shallow:true});
const removeQueryParam = (param) => {
const { pathname, query } = router;
const params = new URLSearchParams(query);
params.delete(param);
router.replace(
{ pathname, query: params.toString() },
undefined,
{ shallow: true }
);
};
removeQueryParam('something');
<Link href={{ pathname: "/about", query: { name: "test" } }} as="/about">
<a>Link with hidden query params</a>
</Link>
<Link href='/about' replace> About us </Link>
userRouter
또는 withRouter
)를 통해 업데이트된 pathname
과 query
를 받게 된다.shallow
옵션을 true
로 설정한다.