When I am trying to console query params I am getting empty object and my URL is http://localhost:3000/searchResult?Empid=220
.
My code to set and get the query params is shown here. Using params I need to filter my Emp object and need to display the filtered one. Emp Page:
const handleClick =() => {
const params = new URLSearchParams(location.search)
params.append("Empid", EmployeeId)
history.push({pathname: `/searchResult`,
search:"?" + params})
}
Search Result page:
const params = useParams();
console.log("params", params)
When I tried to console log of parmas I am getting empty object. I am expecting to get Empid=220
as a param.
Thanks in advance.