react-instantsearch-nextjs 1.1.5 → 1.2.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.
|
@@ -81,9 +81,7 @@ function InitializePromise(param) {
|
|
|
81
81
|
waitForResultsRef.current = (0, _reactinstantsearchcore.wrapPromiseWithState)(waitForResults().then(function() {
|
|
82
82
|
var shouldRefetch = false;
|
|
83
83
|
(0, _utils.walkIndex)(search.mainIndex, function(index) {
|
|
84
|
-
shouldRefetch = index.getWidgets().some(
|
|
85
|
-
return widget.$$type === 'ais.dynamicWidgets';
|
|
86
|
-
});
|
|
84
|
+
shouldRefetch = shouldRefetch || index.getWidgets().some(_utils.isTwoPassWidget);
|
|
87
85
|
});
|
|
88
86
|
if (shouldRefetch) {
|
|
89
87
|
var _search__resetScheduleSearch;
|
|
@@ -23,7 +23,21 @@ function useInstantSearchRouting(passedRouting, isMounting) {
|
|
|
23
23
|
var routingRef = (0, _react.useRef)(null);
|
|
24
24
|
var onUpdateRef = (0, _react.useRef)(null);
|
|
25
25
|
var isUnmounting = (0, _react.useRef)(false);
|
|
26
|
+
// Skip the on-mount fire of the effect below: `subscribe()` already merges
|
|
27
|
+
// the URL into `_initialUiState`, and a redundant `setUiState` can wipe the
|
|
28
|
+
// URL with a nested `<Index>` (see #6980).
|
|
29
|
+
var previousRouteRef = (0, _react.useRef)(null);
|
|
26
30
|
(0, _react.useEffect)(function() {
|
|
31
|
+
var _ref;
|
|
32
|
+
var currentRoute = "".concat(pathname !== null && pathname !== void 0 ? pathname : '', "?").concat((_ref = searchParams === null || searchParams === void 0 ? void 0 : searchParams.toString()) !== null && _ref !== void 0 ? _ref : '');
|
|
33
|
+
if (previousRouteRef.current === currentRoute) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
var isFirstRun = previousRouteRef.current === null;
|
|
37
|
+
previousRouteRef.current = currentRoute;
|
|
38
|
+
if (isFirstRun) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
27
41
|
if (onUpdateRef.current) {
|
|
28
42
|
onUpdateRef.current();
|
|
29
43
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _$1 } from '@swc/helpers/esm/_object_spread.js';
|
|
2
2
|
import { _ } from '@swc/helpers/esm/_object_spread_props.js';
|
|
3
3
|
import { getInitialResults } from 'instantsearch.js/es/lib/server.js';
|
|
4
|
-
import { resetWidgetId, walkIndex } from 'instantsearch.js/es/lib/utils/index.js';
|
|
4
|
+
import { resetWidgetId, walkIndex, isTwoPassWidget } from 'instantsearch.js/es/lib/utils/index.js';
|
|
5
5
|
import { ServerInsertedHTMLContext } from 'next/navigation.js';
|
|
6
6
|
import { useContext } from 'react';
|
|
7
7
|
import { useInstantSearchContext, useRSCContext, wrapPromiseWithState } from 'react-instantsearch-core';
|
|
@@ -71,9 +71,7 @@ function InitializePromise(param) {
|
|
|
71
71
|
waitForResultsRef.current = wrapPromiseWithState(waitForResults().then(function() {
|
|
72
72
|
var shouldRefetch = false;
|
|
73
73
|
walkIndex(search.mainIndex, function(index) {
|
|
74
|
-
shouldRefetch = index.getWidgets().some(
|
|
75
|
-
return widget.$$type === 'ais.dynamicWidgets';
|
|
76
|
-
});
|
|
74
|
+
shouldRefetch = shouldRefetch || index.getWidgets().some(isTwoPassWidget);
|
|
77
75
|
});
|
|
78
76
|
if (shouldRefetch) {
|
|
79
77
|
var _search__resetScheduleSearch;
|
|
@@ -12,7 +12,21 @@ function useInstantSearchRouting(passedRouting, isMounting) {
|
|
|
12
12
|
var routingRef = useRef(null);
|
|
13
13
|
var onUpdateRef = useRef(null);
|
|
14
14
|
var isUnmounting = useRef(false);
|
|
15
|
+
// Skip the on-mount fire of the effect below: `subscribe()` already merges
|
|
16
|
+
// the URL into `_initialUiState`, and a redundant `setUiState` can wipe the
|
|
17
|
+
// URL with a nested `<Index>` (see #6980).
|
|
18
|
+
var previousRouteRef = useRef(null);
|
|
15
19
|
useEffect(function() {
|
|
20
|
+
var _ref;
|
|
21
|
+
var currentRoute = "".concat(pathname !== null && pathname !== void 0 ? pathname : '', "?").concat((_ref = searchParams === null || searchParams === void 0 ? void 0 : searchParams.toString()) !== null && _ref !== void 0 ? _ref : '');
|
|
22
|
+
if (previousRouteRef.current === currentRoute) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
var isFirstRun = previousRouteRef.current === null;
|
|
26
|
+
previousRouteRef.current = currentRoute;
|
|
27
|
+
if (isFirstRun) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
16
30
|
if (onUpdateRef.current) {
|
|
17
31
|
onUpdateRef.current();
|
|
18
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-instantsearch-nextjs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "React InstantSearch SSR utilities for Next.js",
|
|
5
5
|
"types": "dist/es/index.d.ts",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@playwright/test": "1.49.1",
|
|
55
|
-
"instantsearch.js": "4.
|
|
55
|
+
"instantsearch.js": "4.96.0",
|
|
56
56
|
"next": "16.0.7",
|
|
57
|
-
"react-instantsearch-core": "7.
|
|
57
|
+
"react-instantsearch-core": "7.32.0",
|
|
58
58
|
"start-server-and-test": "1.15.3",
|
|
59
59
|
"ts-node": "8.4.1"
|
|
60
60
|
},
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"next": ">= 13.4 < 17",
|
|
63
63
|
"react-instantsearch": ">= 7.1.0 < 8"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "17e816d7f2c0c3ace2552f9e5322a2e45d6c3492"
|
|
66
66
|
}
|