Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: "TypeError: defaultSearchParams.keys() is not iterable" in Firefox Addon content scripts #10618

Closed
smithki opened this issue Jun 16, 2023 · 3 comments
Labels

Comments

@smithki
Copy link
Contributor

smithki commented Jun 16, 2023

What version of React Router are you using?

6.11.0

Steps to Reproduce

There is a known issue in Firefox — still open after 9 years — that manifests in the following TypeError when using React Router DOM in the content scripts of a Firefox Addon:

Screenshot 2023-06-16 at 4 26 29 PM
TypeError: defaultSearchParams.keys() is not iterable[dom.ts:100:40](moz-extension://ea565e18-3799-46da-aa12-608dc044d7e7/node_modules/react-router-dom/dom.ts)
    getSearchParamsForLocation dom.ts:100

Here's a link to the relevant Bugzilla ticket: https://bugzilla.mozilla.org/show_bug.cgi?id=1023984

Expected Behavior

useSearchParams doesn't not produce an error.

Actual Behavior

React experiences a fatal error at runtime, including recursive "Invalid hook call" warnings. This is a showstopper for anyone who wants to use React Router DOM in a web extension (for my case, paired with MemoryRouter to simplify routing for UIs that are injected into content scripts).

@smithki smithki added the bug label Jun 16, 2023
@smithki
Copy link
Contributor Author

smithki commented Jun 16, 2023

Though this is ultimately a shortcoming of Firefox, I've confirmed that a small change to getSearchParamsForLocation() should fix the bug and enable the web extension use-case.

// line 100 in packages/react-router-dom/dom.ts
for (let key of defaultSearchParams.keys()) {

should become:

defaultSearchParams.forEach((key) => { ...

Happy to create a PR with this fix if the maintainers are amenable to it. For now I've implemented this patch manually into my code, but would much rather depend on React Router directly for search params.

@brophdawg11 brophdawg11 added the awaiting release This issue have been fixed and will be released soon label Jul 13, 2023
@brophdawg11
Copy link
Contributor

This is fixed by #10620. It merged to dev after we started the release process for 6.14.2 (currently in prerelease), so it'll be available in the next release after that 👍

@brophdawg11
Copy link
Contributor

We just published version 6.15.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

@brophdawg11 brophdawg11 removed the awaiting release This issue have been fixed and will be released soon label Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants