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

chore(deps): update algoliasearch-client-javascript monorepo to v5 (major) #7979

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 1 addition & 3 deletions examples/react/algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
"test:types": "tsc"
},
"dependencies": {
"@algolia/client-search": "4.24.0",
"@algolia/transporter": "4.24.0",
"@algolia/client-search": "5.2.1",
"@tanstack/react-query": "^5.52.2",
"@tanstack/react-query-devtools": "^5.52.2",
"algoliasearch": "4.24.0",
"react": "19.0.0-rc-4c2e457c7c-20240522",
"react-dom": "19.0.0-rc-4c2e457c7c-20240522"
},
Expand Down
17 changes: 8 additions & 9 deletions examples/react/algolia/src/algolia.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import algoliasearch from 'algoliasearch'
import { Hit } from '@algolia/client-search'
import { searchClient } from '@algolia/client-search'
import type { Hit } from '@algolia/client-search'

// From Algolia example
// https://github.com/algolia/react-instantsearch
Expand All @@ -19,17 +19,16 @@ export async function search<TData>({
pageParam,
hitsPerPage = 10,
}: SearchOptions): Promise<{
hits: Hit<TData>[]
hits: Array<Hit<TData>>
nextPage: number | undefined
}> {
const client = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY)
const index = client.initIndex(indexName)
const client = searchClient(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY)

console.log('alogolia:search', { indexName, query, pageParam, hitsPerPage })
console.log('algolia:search', { indexName, query, pageParam, hitsPerPage })

const { hits, page, nbPages } = await index.search<TData>(query, {
page: pageParam,
hitsPerPage,
const { hits, page, nbPages } = await client.searchSingleIndex<TData>({
indexName,
searchParams: { query, page: pageParam, hitsPerPage },
})

const nextPage = page + 1 < nbPages ? page + 1 : undefined
Expand Down
4 changes: 2 additions & 2 deletions examples/react/algolia/src/useAlgolia.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useInfiniteQuery, skipToken } from '@tanstack/react-query'
import { skipToken, useInfiniteQuery } from '@tanstack/react-query'
import { search } from './algolia'

export type UseAlgoliaOptions = {
Expand All @@ -23,7 +23,7 @@ export default function useAlgolia<TData>({
search<TData>({ indexName, query, pageParam, hitsPerPage })
: skipToken,
initialPageParam: 0,
getNextPageParam: (lastPage) => lastPage?.nextPage,
getNextPageParam: (lastPage) => lastPage.nextPage,
staleTime,
gcTime,
})
Expand Down
182 changes: 36 additions & 146 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading