Consider doing this:
const { pathname } = useLocation()
const { param1, param2 } = useParams()
const { push } = useHistory()
instead of:
const location = useLocation()
const params = useParams()
const history = useHistory()
const { pathname } = location
const { param1, param2 } = params
const { push } = history
Implementation:
console.log(pathname, param1, param2)
push('/next-route')
Despite being shorter in syntax, does the object destructuring in the former case bring in all properties of an object first and then assign single property to a new variable? If that's how JS works, the case then it would mean a slightly bigger load to the component. If not, there is nothing to bother about. Right?