0.0.1 • Published 5 years ago

use-browser-search-param v0.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

Peer dependency API error

This error occurs when the history, location, and / or URL provided to usableSearchParams does not exist or is invalid. Either 1) the global environment does not have a valid history, location, and / or URL API; or 2) the custom-provided history, location, and / or URL API is invalid.

In either case, here's what this library needs in terms of a "valid" history, location, and URL API:

  • A "valid" history API must include a pushState method. This library uses history.pushState to change the current search params without causing a page refresh. You can read more about the history API here.
  • A "valid" location API must include a toString method. This library uses location.toString to determine the current value of the address bar when getting or setting search params.
  • A "valid" URL API

Case number one would happen, for example, if you use this library from a non-browser environment (e.g. node or react native) or a browser environment that does not support history, location, or URL. You can find polyfills and shims online (if you want you can read here for more about those terms) to help fill in the missing API(s). No particular polyfills or shims are yet confirmed to work with this library, so if you try one and it works or doesn't work, please tell us about it, so we can update these docs. Here are some links to try anyways:

Case number two would happen, for example, if you improperly configure usableSearchParams to work with react router. If so, make sure you are passing react router's history