Skip to content

Commit

Permalink
♻️ Refactor instant search packages and remove warnings #1114 (#1978)
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandolucchesi authored Nov 17, 2023
1 parent bdb3923 commit 96ec4dc
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 138 deletions.
7 changes: 2 additions & 5 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@
"react-error-boundary": "^3.1.4",
"react-focus-lock": "^2.9.2",
"react-hook-form": "7.45.2",
"react-instantsearch-dom": "^6.40.4",
"react-instantsearch-hooks-router-nextjs": "6.47.3",
"react-instantsearch-hooks-server": "^6.47.3",
"react-instantsearch-hooks-web": "^6.47.3",
"react-instantsearch": "^7.3.0",
"react-instantsearch-router-nextjs": "^7.3.0",
"react-intl": "^6.0.2",
"react-is": "^18.1.0",
"react-remove-scroll": "^2.5.5",
Expand Down Expand Up @@ -102,7 +100,6 @@
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.5",
"@types/react-instantsearch": "^6.10.1",
"@types/react-instantsearch-dom": "^6.12.3",
"@types/styled-components": "^5.1.26",
"@types/testing-library__jest-dom": "^5.14.5",
"babel-plugin-styled-components": "^2.1.1",
Expand Down
5 changes: 3 additions & 2 deletions web/pageComponents/pageTemplates/MagazineIndexPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BackgroundContainer } from '@components'
import { Configure, InstantSearch } from 'react-instantsearch-hooks-web'
import styled from 'styled-components'
import { Flags } from '../../common/helpers/datasetHelpers'
import { searchClient } from '../../lib/algolia'
Expand All @@ -18,9 +17,10 @@ import { PaginationContextProvider } from '../shared/search/pagination/Paginatio
import Teaser from '../shared/Teaser'
import { SharedBanner } from './shared/SharedBanner'
import SharedTitle from './shared/SharedTitle'
import { createInstantSearchRouterNext } from 'react-instantsearch-hooks-router-nextjs'
import singletonRouter from 'next/router'
import type { UiState } from 'instantsearch.js'
import { Configure, InstantSearch } from 'react-instantsearch'
import { createInstantSearchRouterNext } from 'react-instantsearch-router-nextjs'

const IngressWrapper = styled.div`
max-width: 1186px; /* 1920 - (2 * 367) */
Expand Down Expand Up @@ -101,6 +101,7 @@ const MagazineIndexPage = ({ isServerRendered = false, locale, pageData, slug, u
})
: searchClient(undefined)
}
future={{ preserveSharedStateOnUnmount: false }}
indexName={indexName}
routing={{
router: createInstantSearchRouterNext({
Expand Down
7 changes: 4 additions & 3 deletions web/pageComponents/pageTemplates/NewsRoomPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Heading } from '@components'
import { useEffect, useRef } from 'react'
import { Configure, InstantSearch } from 'react-instantsearch-hooks-web'
import { useRef } from 'react'
import { FormattedMessage } from 'react-intl'
import styled from 'styled-components'
import { Flags } from '../../common/helpers/datasetHelpers'
Expand All @@ -18,9 +17,10 @@ import Filters from './newsroom/Filters'
import Hit from './newsroom/Hit'
import { Hits } from './newsroom/Hits'
import { Intro, News, UnpaddedText, Wrapper } from './newsroom/StyledComponents'
import { createInstantSearchRouterNext } from 'react-instantsearch-hooks-router-nextjs'
import { createInstantSearchRouterNext } from 'react-instantsearch-router-nextjs'
import singletonRouter from 'next/router'
import type { UiState } from 'instantsearch.js'
import { Configure, InstantSearch } from 'react-instantsearch'

const NewsRoomContent = styled.div`
display: grid;
Expand Down Expand Up @@ -212,6 +212,7 @@ const NewsRoomPage = ({ isServerRendered, locale, pageData, slug, url }: NewsRoo
})
: searchClient(undefined)
}
future={{ preserveSharedStateOnUnmount: false }}
indexName={indexName}
routing={routing}
>
Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/pageTemplates/newsroom/Hits.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hit as AlgoliaHit } from '@algolia/client-search'
import { useHits, UseHitsProps } from 'react-instantsearch-hooks-web'
import { useHits, UseHitsProps } from 'react-instantsearch'
import { FormattedMessage } from 'react-intl'
import styled from 'styled-components'
import { List } from '@components'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRefinementList, UseRefinementListProps } from 'react-instantsearch-hooks-web'
import { useRefinementList, UseRefinementListProps } from 'react-instantsearch'
import { List, Checkbox } from '@components'
import styled from 'styled-components'
import { FormattedMessage } from 'react-intl'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { useEffect, useRef, useState } from 'react'
import { useSearchBox, UseSearchBoxProps } from 'react-instantsearch-hooks-web'
import { useSearchBox, UseSearchBoxProps } from 'react-instantsearch'
import styled from 'styled-components'
import VisuallyHidden from '../../shared/VisuallyHidden'
import { useIntl } from 'react-intl'
Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/search/Hits.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useHits } from 'react-instantsearch-hooks-web'
import { useHits } from 'react-instantsearch'
import { List, Heading } from '@components'
import styled from 'styled-components'
import { FormattedMessage } from 'react-intl'
Expand Down
14 changes: 9 additions & 5 deletions web/pageComponents/search/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { InstantSearch, Configure, Index } from 'react-instantsearch-hooks-web'
import { InstantSearch, Configure, Index } from 'react-instantsearch'
import { searchClient as client } from '../../lib/algolia'
import dynamic from 'next/dynamic'
import { Flags } from '../../common/helpers/datasetHelpers'
import { SearchBox } from './SearchBox'
import { getIsoFromLocale } from '../../lib/localization'
import { SearchContextProvider } from './SearchContext'
import { createInstantSearchRouterNext } from 'react-instantsearch-hooks-router-nextjs'
import singletonRouter from 'next/router'
import { createInstantSearchRouterNext } from 'react-instantsearch-router-nextjs'
import singletonRouter, { useRouter } from 'next/router'
import type { UiState } from 'instantsearch.js'
import { useRouter } from 'next/router'
import { useRef } from 'react'
import styled from 'styled-components'
import { Pagination } from '../shared/search/pagination/Pagination'
Expand Down Expand Up @@ -158,7 +157,12 @@ const Search = () => {
}

return (
<InstantSearch searchClient={queriedSearchClient} indexName={mainIndex} routing={routing}>
<InstantSearch
future={{ preserveSharedStateOnUnmount: false }}
searchClient={queriedSearchClient}
indexName={mainIndex}
routing={routing}
>
<Configure hitsPerPage={5} snippetEllipsisText="..." />
{indices.map((index) => (
<Index indexName={index.value} key={index.label} indexId={index.value} />
Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/search/SearchBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState, ChangeEvent, ComponentProps, useContext } from 'react'
import { useSearchBox, UseSearchBoxProps } from 'react-instantsearch-hooks-web'
import { useSearchBox, UseSearchBoxProps } from 'react-instantsearch'
import ControlledSearchBox from './ControlledSearchBox'
import { SearchContext } from './SearchContext'

Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/search/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import NewsHit from './NewsHit'
import { SearchContext } from './SearchContext'
import TopicHit from './TopicHit'
import TotalResultsStat from './TotalResultsStat'
import { useSortBy, UseSortByProps, useHits, useInstantSearch } from 'react-instantsearch-hooks-web'
import { useSortBy, UseSortByProps, useHits, useInstantSearch } from 'react-instantsearch'

const Results = styled.div`
margin-top: var(--space-xLarge);
Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/search/TotalResultsStat.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { usePagination, UsePaginationProps } from 'react-instantsearch-hooks-web'
import { usePagination, UsePaginationProps } from 'react-instantsearch'
import { FormattedMessage } from 'react-intl'
import styled from 'styled-components'

Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/searchIndexPages/magazineIndex/Hits.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useHits, UseHitsProps } from 'react-instantsearch-hooks-web'
import { useHits, UseHitsProps } from 'react-instantsearch'
import { FormattedMessage } from 'react-intl'
import styled from 'styled-components'
import MagazineCard from '../../cards/MagazineCard'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forwardRef } from 'react'
import { useMenu, UseMenuProps, useClearRefinements, useCurrentRefinements } from 'react-instantsearch-hooks-web'
import { useMenu, UseMenuProps, useClearRefinements, useCurrentRefinements } from 'react-instantsearch'
import MagazineTagBar from '../../shared/MagazineTagBar'

export type RefinementListProps = { tags: string[] } & React.ComponentProps<'div'> & UseMenuProps
Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/shared/search/pagination/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Icon } from '@equinor/eds-core-react'
import { chevron_left, chevron_right, first_page, last_page } from '@equinor/eds-icons'
import { useContext, useEffect, useRef } from 'react'
import { usePagination, UsePaginationProps } from 'react-instantsearch-hooks-web'
import { usePagination, UsePaginationProps } from 'react-instantsearch'
import styled from 'styled-components'
import { usePrefersReducedMotion } from '../../../../common/hooks/usePrefersReducedMotion'
import { PaginationContext } from './PaginationContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { usePagination } from 'react-instantsearch-hooks-web'
import { usePagination } from 'react-instantsearch'
import { Button } from '@components'
import styled from 'styled-components'

Expand Down
3 changes: 1 addition & 2 deletions web/pages/magasin/index.global.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { GetServerSideProps } from 'next'
import { InstantSearchSSRProvider } from 'react-instantsearch-hooks-web'
import { getServerState } from 'react-instantsearch-hooks-server'
import { InstantSearchSSRProvider, getServerState } from 'react-instantsearch'
import type { AppProps } from 'next/app'
import { IntlProvider } from 'react-intl'
import Footer from '../../pageComponents/shared/Footer'
Expand Down
4 changes: 2 additions & 2 deletions web/pages/magazine/index.global.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GetServerSideProps } from 'next'
import { InstantSearchSSRProvider } from 'react-instantsearch-hooks-web'
import { getServerState } from 'react-instantsearch-hooks-server'
import { InstantSearchSSRProvider } from 'react-instantsearch'
import { getServerState } from 'react-instantsearch'
import type { AppProps } from 'next/app'
import { IntlProvider } from 'react-intl'
import Footer from '../../pageComponents/shared/Footer'
Expand Down
3 changes: 1 addition & 2 deletions web/pages/news/index.global.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { GetServerSideProps } from 'next'
import { InstantSearchSSRProvider } from 'react-instantsearch-hooks-web'
import { getServerState } from 'react-instantsearch-hooks-server'
import { InstantSearchSSRProvider, getServerState } from 'react-instantsearch'
import type { AppProps } from 'next/app'
import { IntlProvider } from 'react-intl'
import Footer from '../../pageComponents/shared/Footer'
Expand Down
3 changes: 1 addition & 2 deletions web/pages/nyheter/index.global.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { GetServerSideProps } from 'next'
import { InstantSearchSSRProvider } from 'react-instantsearch-hooks-web'
import { getServerState } from 'react-instantsearch-hooks-server'
import { InstantSearchSSRProvider, getServerState } from 'react-instantsearch'
import type { AppProps } from 'next/app'
import { IntlProvider } from 'react-intl'
import Footer from '../../pageComponents/shared/Footer'
Expand Down
Loading

0 comments on commit 96ec4dc

Please sign in to comment.