Skip to content

Commit 350fb42

Browse files
authored
fix(react-instantsearch): use → addMiddlewares (#464)
1 parent bcc1e6e commit 350fb42

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

react-instantsearch/facet-dropdown/src/components/FacetDropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ function DropdownMiddleware({
5959
closeOnChange,
6060
close,
6161
}: MiddlewareProps) {
62-
const { use } = useInstantSearch();
62+
const { addMiddlewares } = useInstantSearch();
6363

6464
useEffect(() =>
65-
use(() => ({
65+
addMiddlewares(() => ({
6666
onStateChange() {
6767
const shouldCloseOnChange =
6868
closeOnChange === true ||

react-instantsearch/remix/components/ScrollTo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ type ScrollToProps = ComponentProps<'div'> & {
77
};
88

99
export function ScrollTo({ children, ...props }: ScrollToProps) {
10-
const { use } = useInstantSearch();
10+
const { addMiddlewares } = useInstantSearch();
1111
const containerRef = useRef<HTMLDivElement>(null);
1212

1313
useEffect(() => {
14-
return use(() => {
14+
return addMiddlewares(() => {
1515
return {
1616
onStateChange() {
1717
const isFiltering = document.body.classList.contains('filtering');
@@ -27,7 +27,7 @@ export function ScrollTo({ children, ...props }: ScrollToProps) {
2727
},
2828
};
2929
});
30-
}, [use]);
30+
}, [addMiddlewares]);
3131

3232
return (
3333
<div {...props} ref={containerRef}>

react-instantsearch/remix/components/SearchErrorToast.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import * as Toast from '@radix-ui/react-toast';
33
import { useInstantSearch } from 'react-instantsearch';
44

55
export function SearchErrorToast() {
6-
const { use } = useInstantSearch();
6+
const { addMiddlewares } = useInstantSearch();
77
const [error, setError] = useState<Error | null>(null);
88

99
useEffect(() => {
10-
return use(({ instantSearchInstance }) => {
10+
return addMiddlewares(({ instantSearchInstance }) => {
1111
function handleError(searchError: Error) {
1212
setError(searchError);
1313
}
@@ -21,7 +21,7 @@ export function SearchErrorToast() {
2121
},
2222
};
2323
});
24-
}, [use]);
24+
}, [addMiddlewares]);
2525

2626
if (!error) {
2727
return null;

0 commit comments

Comments
 (0)