DEV Community

Discussion on: How to Use URL Query String Parameters in Gatsby

Collapse
 
dandv profile image
Dan Dascalescu

Is it necessary to useLocation? Gatsby passes location via props to any component.

Collapse
 
5t3ph profile image
Stephanie Eckles

If I'm understanding correctly, location is provided to "page" components, whereas this is a functional component/hook combo for flexibility in accessing this information.

The main reason for the additional install is this came from a project using Typescript so it needed to be explicitly defined in the package to avoid linting errors/leverage intellisense.

But thanks for bringing that to my attention, I'm sure it would be useful in other scenarios!