DEV Community

Discussion on: The Easiest Way to Use Query Parameters in React

Collapse
 
remcohoff profile image
Remco Hoff

Hi Brett, thanks for sharing your code with us.
When I copy and paste your code in my own project though, I get this linting error:
"Parsing error: Cannot read property 'map' of undefined"

I think it has to do with this line of code: "const useQueryParam = ( key: string, defaultVal: string): [string, (val: string) => void] => {"

When I remove the part ": [string, (val: string) => void]" the error message is gone, but things don't work anymore.

I'm new to Typescript, could you explain what is happening in this line of code and perhaps share any ideas on how to fix the linting error?

Thanks in advance.
Remco Hoff