dry-ux 1.78.0 → 1.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -325,20 +325,24 @@ exports.useDimensions = useDimensions;
|
|
|
325
325
|
*/
|
|
326
326
|
const useSearchParams = () => {
|
|
327
327
|
const [params, setParams] = React.useState((0, exports.getUrlParams)());
|
|
328
|
+
const crossHookEventName = "dry-ux-use-search-params-update";
|
|
329
|
+
const { usePub, useSub } = (0, exports.usePubSub)();
|
|
330
|
+
const publish = usePub();
|
|
328
331
|
/**
|
|
329
332
|
* Sets a URL parameter and updates the state.
|
|
330
333
|
*/
|
|
331
334
|
const setParam = React.useCallback((key, value) => {
|
|
332
335
|
(0, exports.insertUrlParam)(key, value);
|
|
333
|
-
|
|
336
|
+
publish(crossHookEventName);
|
|
334
337
|
}, []);
|
|
335
338
|
/**
|
|
336
339
|
* Clears one or more URL parameters and updates the state.
|
|
337
340
|
*/
|
|
338
341
|
const clearParams = React.useCallback((...keys) => {
|
|
339
342
|
keys.forEach(key => (0, exports.deleteUrlParam)(key));
|
|
340
|
-
|
|
343
|
+
publish(crossHookEventName);
|
|
341
344
|
}, []);
|
|
345
|
+
useSub(crossHookEventName, () => setParams((0, exports.getUrlParams)()));
|
|
342
346
|
return {
|
|
343
347
|
params,
|
|
344
348
|
setParam,
|