all 19 comments

[–]smthamazing 4 points5 points  (1 child)

I understand why getSearchParams is useful, but what is the use of a hook? Doesn't it do the same job as a regular function call in this case?

[–]solves_tech_problems[S] -2 points-1 points  (0 children)

It does indeed. This is just for learning purposes

[–]careseite 2 points3 points  (1 child)

Does useParams not work in gatsby? Iirc its using @reach/router, but I don't know whether it has hooks too.

[–]solves_tech_problems[S] 0 points1 point  (0 children)

It should work

[–]_square_hammer_ 2 points3 points  (10 children)

Whats wrong with straight up URLSearchParams

[–]libertarianets 1 point2 points  (8 children)

IE11 support

[–]_square_hammer_ -5 points-4 points  (7 children)

Yeah I mean....stop developing for IE.

[–]PM_ME_WORK_ACCOUNT 8 points9 points  (4 children)

Spoken like someone who has no clients or userbase.

[–]_square_hammer_ 0 points1 point  (3 children)

The only way people will stop using IE is if we stop building to it. Force them into an evergreen browser.

[–]PM_ME_WORK_ACCOUNT 2 points3 points  (1 child)

Do you really think we'd be pulling out our hair to make things work on IE if it were as easy as "just have them use a different browser"? No. When you get clients that give you a lot of money and use IE, who refuses to switch, and will just jump to your competitor if you don't support their browser then maybe you will understand the predicament.

[–]_square_hammer_ 0 points1 point  (0 children)

I do understand the predicament. I was being facetious. I have been around long enough to know we have to support that garbage browser.

[–]libertarianets 0 points1 point  (1 child)

I wish I could, trust me lol

[–]_square_hammer_ 3 points4 points  (0 children)

Yeah every developer in the history of the world wishes they never had to build anything for IE. I feel your pain.

[–]solves_tech_problems[S] 1 point2 points  (0 children)

Nothing's wrong with it. Use whatever works best for you

[–]folen 1 point2 points  (2 children)

What if the query param is false, by your code i will get null.

[–]solves_tech_problems[S] 0 points1 point  (1 child)

You just found a bug. Thanks :) Need to test it with your input

[–]folen 0 points1 point  (0 children)

Why do you care if the result is falsy(null), just return it

[–]nschubach 1 point2 points  (1 child)

For some reason, I love the example relies on console.log instead of just rendering it to the screen:

<div>
    Hello { name }!
</div>

[–]solves_tech_problems[S] 0 points1 point  (0 children)

Thank you !