useSearchParam

A React Hook that gets a search parameter from a URL and calls a provided setter function with the corresponding value.

Parameters

Name Type Description
props Object An object containing the parameter and setter function.
props.parameter String The parameter to search for
props.setValue function A setter function that is passed the parameter value found in the URL

Source Code: pwa-studio/packages/peregrine/lib/hooks/useSearchParam.js

Example

The following example, uses the useSearchParam() hook to get the query parameter from the URL.