@supunlakmal/hooks
Version:
A collection of reusable React hooks
12 lines (11 loc) • 669 B
TypeScript
/**
* Custom hook to synchronize a state variable with a URL query parameter.
* Note: This basic version only handles string values.
*
* @param {string} paramName The name of the URL query parameter.
* @param {string} [initialValue=''] The default value to use if the parameter is not in the URL.
* @returns {[string, (newValue: string | null) => void]} A tuple containing:
* - The current value of the query parameter state.
* - A function to update the state and the URL query parameter (pass null to remove).
*/
export declare const useQueryParam: (paramName: string, initialValue?: string) => [string, (newValue: string | null) => void];