Access the `location` prop in Gatsby
See here for the original answer.
You should have the location
variable already defined, it is likely in the global scope so you don't need to pass it as a parameter to the function. Try just using the variable and see if that works.