Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for React 19 #6520

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/react/default-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"algoliasearch": "5.1.1",
"instantsearch.css": "8.5.1",
"instantsearch.js": "4.75.7",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-instantsearch": "7.13.10"
},
"devDependencies": {
"@parcel/core": "2.10.0",
"@parcel/packager-raw-url": "2.10.0",
"@parcel/transformer-webmanifest": "2.10.0",
"@types/react": "^18.0.9",
"@types/react": "19.0.3",
"parcel": "2.10.0",
"typescript": "5.5.2"
},
Expand Down
4 changes: 3 additions & 1 deletion examples/react/default-theme/src/components/layout/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export function Tabs({ children }: { children: React.ReactNode }) {
id={getTabId(index, 'title')}
tabIndex={isSelected ? 0 : -1}
className={cx('Tabs-title', isSelected && 'Tabs-title--active')}
ref={(element) => (tabsRefs.current[index] = element!)}
ref={(element) => {
tabsRefs.current[index] = element!;
}}
key={getTabId(index)}
onClick={() => setCurrentTab(index)}
onKeyDown={onKeyDown}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useClearRefinements } from 'react-instantsearch';
export function ClearFiltersMobile({
containerRef,
}: {
containerRef: React.RefObject<HTMLElement>;
containerRef: React.RefObject<HTMLElement | null>;
}) {
const { refine } = useClearRefinements();

Expand Down
6 changes: 3 additions & 3 deletions examples/react/e-commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
"algoliasearch": "5.1.1",
"instantsearch.css": "8.5.1",
"instantsearch.js": "4.75.7",
"react": "18.2.0",
"react": "19.0.0",
"react-compound-slider": "3.4.0",
"react-dom": "18.2.0",
"react-dom": "19.0.0",
"react-instantsearch": "7.13.10"
},
"devDependencies": {
"@parcel/core": "2.10.0",
"@parcel/packager-raw-url": "2.10.0",
"@parcel/transformer-webmanifest": "2.10.0",
"@types/react": "^18.0.9",
"@types/react": "19.0.3",
"parcel": "2.10.0",
"typescript": "5.5.2"
},
Expand Down
6 changes: 3 additions & 3 deletions examples/react/getting-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"algoliasearch": "5.1.1",
"instantsearch.css": "8.5.1",
"instantsearch.js": "4.75.7",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-instantsearch": "7.13.10"
},
"devDependencies": {
"@parcel/core": "2.10.0",
"@parcel/packager-raw-url": "2.10.0",
"@parcel/transformer-webmanifest": "2.10.0",
"@types/react": "^18.0.9",
"@types/react": "19.0.3",
"parcel": "2.10.0",
"typescript": "5.5.2"
},
Expand Down
6 changes: 3 additions & 3 deletions examples/react/next-app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"algoliasearch": "5.1.1",
"instantsearch.css": "8.5.1",
"next": "13.5.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-instantsearch": "7.13.10",
"react-instantsearch-nextjs": "0.3.21"
},
"devDependencies": {
"@types/node": "17.0.40",
"@types/react": "18.0.12",
"@types/react": "19.0.3",
"eslint": "8.4.0",
"eslint-config-next": "12.0.7",
"typescript": "5.5.2"
Expand Down
6 changes: 3 additions & 3 deletions examples/react/next-routing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"algoliasearch": "5.1.1",
"instantsearch.css": "8.5.1",
"next": "13.5.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-instantsearch": "7.13.10",
"react-instantsearch-router-nextjs": "7.13.10"
},
"devDependencies": {
"@types/node": "17.0.40",
"@types/react": "18.0.12",
"@types/react": "19.0.3",
"eslint": "8.4.0",
"eslint-config-next": "12.0.7",
"typescript": "5.5.2"
Expand Down
6 changes: 3 additions & 3 deletions examples/react/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"algoliasearch": "5.1.1",
"instantsearch.css": "8.5.1",
"next": "13.5.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-instantsearch": "7.13.10",
"react-instantsearch-router-nextjs": "7.13.10"
},
"devDependencies": {
"@types/node": "17.0.40",
"@types/react": "18.0.12",
"@types/react": "19.0.3",
"eslint": "8.4.0",
"eslint-config-next": "12.0.7",
"typescript": "5.5.2"
Expand Down
4 changes: 2 additions & 2 deletions examples/react/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"dependencies": {
"algoliasearch": "5.1.1",
"express": "4.17.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-instantsearch": "7.13.10"
}
}
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,17 @@
"@testing-library/dom": "8.18.1",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/preact": "3.2.2",
"@testing-library/react": "13.2.0",
"@testing-library/react-hooks": "7.0.2",
"@testing-library/react": "16.1.0",
"@testing-library/user-event": "13.5.0",
"@types/enzyme": "^3.1.15",
"@types/googlemaps": "^3.30.16",
"@types/jest": "^27.4.0",
"@types/jest-diff": "^24.3.0",
"@types/jsdom": "16.2.13",
"@types/prop-types": "^15.5.8",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.5",
"@types/react-test-renderer": "^18.0.0",
"@types/react": "19.0.3",
"@types/react-dom": "19.0.2",
"@types/react-test-renderer": "19.0.0",
"@types/storybook__addon-actions": "3.4.2",
"@types/storybook__addon-knobs": "^5.0.0",
"@typescript-eslint/eslint-plugin": "5.38.1",
Expand Down Expand Up @@ -126,9 +125,9 @@
"places.js": "1.17.1",
"prettier": "^2.4.1",
"prop-types": "15.6.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-test-renderer": "18.2.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-test-renderer": "19.0.0",
"rheostat": "2.2.0",
"rollup": "1.29.1",
"rollup-plugin-babel": "4.3.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import type {
} from '../types';

type HighlightPartProps = {
children: ComponentChildren;
children?: ComponentChildren;
classNames: Partial<HighlightClassNames>;
highlightedTagName: ElementType;
nonHighlightedTagName: ElementType;
isHighlighted: boolean;
key?: string | number;
};

function createHighlightPartComponent({ createElement }: Renderer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export type HitsProps<THit> = ComponentProps<'div'> & {
className: string;
onClick: () => void;
onAuxClick: () => void;
key?: string | number;
}) => JSX.Element;
sendEvent: SendEventForHits;
classNames?: Partial<HitsClassNames>;
Expand Down
6 changes: 4 additions & 2 deletions packages/instantsearch-ui-components/src/types/Renderer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* eslint-disable @typescript-eslint/no-namespace */
/* eslint-disable @typescript-eslint/no-empty-interface */

import type { JSX as ReactJSX } from 'react';
Haroenv marked this conversation as resolved.
Show resolved Hide resolved

// Ensure that the JSX namespace is available in this file and its dependents.
declare global {
namespace JSX {
interface Element {}
interface IntrinsicElements {}
interface Element extends ReactJSX.Element {}
interface IntrinsicElements extends ReactJSX.IntrinsicElements {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react-instantsearch-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
},
"peerDependencies": {
"algoliasearch": ">= 3.1 < 6",
"react": ">= 16.8.0 < 19"
"react": ">= 16.8.0 < 20"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export function DynamicWidgets({
);
}

function isReactElement(element: any): element is ReactElement {
function isReactElement(
element: any
): element is ReactElement<Record<string, any>> {
return typeof element === 'object' && element.props;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ describe('InstantSearch', () => {
}),
},
]);
expect(warn).toHaveBeenCalledTimes(4);
expect(warn).toHaveBeenCalledTimes(3);
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/**
* @jest-environment jsdom
*/

import {
createSearchClient,
createMultiSearchResponse,
createSingleSearchResponse,
} from '@instantsearch/mocks';
import { createInstantSearchTestWrapper } from '@instantsearch/testutils';
import { renderHook } from '@testing-library/react-hooks';
import { renderHook, waitFor } from '@testing-library/react';
import React from 'react';

import { useBreadcrumb } from '../useBreadcrumb';
Expand All @@ -16,7 +20,7 @@ import type { MockSearchClient } from '@instantsearch/mocks';
describe('useBreadcrumb', () => {
it('returns the connector render state', async () => {
const wrapper = createInstantSearchTestWrapper();
const { result, waitForNextUpdate } = renderHook(
const { result } = renderHook(
() =>
useBreadcrumb({
attributes: [
Expand All @@ -38,14 +42,14 @@ describe('useBreadcrumb', () => {
refine: expect.any(Function),
});

await waitForNextUpdate();

// InstantSearch.js state from the `render` lifecycle step
expect(result.current).toEqual({
canRefine: false,
createURL: expect.any(Function),
items: [],
refine: expect.any(Function),
await waitFor(() => {
// InstantSearch.js state from the `render` lifecycle step
expect(result.current).toEqual({
canRefine: false,
createURL: expect.any(Function),
items: [],
refine: expect.any(Function),
});
});
});

Expand Down Expand Up @@ -98,7 +102,7 @@ describe('useBreadcrumb', () => {
) as MockSearchClient['search'],
}),
});
const { result, waitForNextUpdate } = renderHook(
const { result } = renderHook(
() =>
useBreadcrumb({
attributes: [
Expand Down Expand Up @@ -134,28 +138,28 @@ describe('useBreadcrumb', () => {
refine: expect.any(Function),
});

await waitForNextUpdate();

// InstantSearch.js state from the `render` lifecycle step
expect(result.current).toEqual({
canRefine: true,
createURL: expect.any(Function),
items: [
{
label: 'Appliances',
value: 'Appliances > Small Kitchen Appliances',
},
{
label: 'Small Kitchen Appliances',
value:
'Appliances > Small Kitchen Appliances > Coffee, Tea & Espresso',
},
{
label: 'Coffee, Tea & Espresso',
value: null,
},
],
refine: expect.any(Function),
await waitFor(() => {
// InstantSearch.js state from the `render` lifecycle step
expect(result.current).toEqual({
canRefine: true,
createURL: expect.any(Function),
items: [
{
label: 'Appliances',
value: 'Appliances > Small Kitchen Appliances',
},
{
label: 'Small Kitchen Appliances',
value:
'Appliances > Small Kitchen Appliances > Coffee, Tea & Espresso',
},
{
label: 'Coffee, Tea & Espresso',
value: null,
},
],
refine: expect.any(Function),
});
});
});
});
Expand Down
Loading
Loading