Skip to content

Commit

Permalink
deps(Algolia): upgrade React InstantSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Jan 17, 2024
1 parent 11c7305 commit 252e2f3
Show file tree
Hide file tree
Showing 6 changed files with 285 additions and 80 deletions.
2 changes: 1 addition & 1 deletion app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ApolloProvider } from '@apollo/client'
// Import libs
import React from 'react'
import { I18nextProvider } from 'react-i18next'
import { Configure, Index, InstantSearch } from 'react-instantsearch-dom'
import { Configure, Index, InstantSearch } from 'react-instantsearch'
import { Provider as ReduxProvider } from 'react-redux'
import { polyfill as smoothSrollPolyfill } from 'smoothscroll-polyfill'
import { ThemeProvider } from 'styled-components'
Expand Down
2 changes: 1 addition & 1 deletion app/components/Search/IndexSearchEntriesCount.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { get } from 'lodash'
import PropTypes from 'prop-types'
import React from 'react'
import { connectStateResults, Index } from 'react-instantsearch-dom'
import { connectStateResults, Index } from 'react-instantsearch'

const SearchResultsCount = connectStateResults(({ searchResults }) => {
return get(searchResults, 'nbHits', 0)
Expand Down
2 changes: 1 addition & 1 deletion app/components/Search/SearchBox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { withNamespaces } from 'react-i18next'
import { SearchBox as AlgoliaSearchBox } from 'react-instantsearch-dom'
import { SearchBox as AlgoliaSearchBox } from 'react-instantsearch'
import { withRouter } from 'react-router'
import styled from 'styled-components'

Expand Down
12 changes: 11 additions & 1 deletion app/components/Search/SearchPage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { capitalize } from 'lodash'
import React from 'react'
import { Trans, withNamespaces } from 'react-i18next'
import { connectSearchBox, Index, InfiniteHits } from 'react-instantsearch-dom'
import { Index, InfiniteHits, useSearchBox } from 'react-instantsearch'
import { Link } from 'react-router-dom'
import styled from 'styled-components'
import { Search as SearchIcon } from 'styled-icons/fa-solid'
Expand Down Expand Up @@ -173,4 +173,14 @@ const SearchPage = ({ t, refine, match, location }) => {
)
}

function connectSearchBox(Component) {
const SearchBox = (props) => {
const data = useSearchBox(props)

return <Component {...props} {...data} />
}

return SearchBox
}

export default withNamespaces('main')(connectSearchBox(SearchPage))
Loading

0 comments on commit 252e2f3

Please sign in to comment.