react-better-html 1.1.69 → 1.1.70
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.
- package/dist/utils/hooks.js +4 -0
- package/package.json +1 -1
package/dist/utils/hooks.js
CHANGED
|
@@ -413,6 +413,10 @@ function useUrlQuery() {
|
|
|
413
413
|
if (!reactRouterDomPlugin) {
|
|
414
414
|
throw new Error("`useUrlQuery` hook requires the `react-router-dom` plugin to be added to the `plugins` prop in `<BetterHtmlProvider>`.");
|
|
415
415
|
}
|
|
416
|
+
const isInRouterContext = (0, react_router_dom_1.useInRouterContext)();
|
|
417
|
+
if (!isInRouterContext) {
|
|
418
|
+
throw new Error("`useUrlQuery` hook must be used inside a React Router context. Make sure your component is wrapped in a `<BrowserRouter>`, or another Router component.");
|
|
419
|
+
}
|
|
416
420
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
417
421
|
const [searchParams] = (0, react_router_dom_1.useSearchParams)();
|
|
418
422
|
const setQuery = (0, react_1.useCallback)((query, keepHistory = true) => {
|