Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

fix(compat): upgrade React Router v3 example lifecycles #2314

Merged

Conversation

francoischalifour
Copy link
Member

This migrates away the React Router v3 example from deprecated React lifecycles.

@francoischalifour francoischalifour requested a review from a team April 12, 2019 10:03
@algobot
Copy link
Contributor

algobot commented Apr 12, 2019

Deploy preview for react-instantsearch ready!

Built with commit cef0888

https://deploy-preview-2314--react-instantsearch.netlify.com

Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks equivalent to me!

@francoischalifour francoischalifour force-pushed the fix/lifecycles-react-router-v3-example branch from 72bbe89 to cef0888 Compare April 23, 2019 08:43
@francoischalifour francoischalifour merged commit 65c8663 into fix/life-cycles Apr 23, 2019
@francoischalifour francoischalifour deleted the fix/lifecycles-react-router-v3-example branch April 23, 2019 13:32
Haroenv added a commit that referenced this pull request Aug 21, 2019
# [6.0.0-beta.0](v5.7.0...v6.0.0-beta.0) (2019-08-21)

### Bug Fixes

* **compat:** upgrade Next.js example lifecycles ([#2379](#2379)) ([45939bc](45939bc))
* **compat:** upgrade RangeInput lifecycle ([#2289](#2289)) ([110b1af](110b1af))
* **compat:** upgrade RangeSlider lifecycle ([#2290](#2290)) ([69a7f53](69a7f53))
* **compat:** upgrade React Native example and its lifecycles ([#2304](#2304)) ([f390c17](f390c17))
* **compat:** upgrade React Router example lifecycles ([#2307](#2307)) ([ab828b0](ab828b0))
* **compat:** upgrade React Router v3 example lifecycles ([#2314](#2314)) ([3647154](3647154))
* **compat:** upgrade SearchBox lifecycle ([#2288](#2288)) ([c3ba42d](c3ba42d))
* **compat:** upgrade Tourism example lifecycles ([#2305](#2305)) ([fff5aa6](fff5aa6))
* **connectToggleRefinement:** cast currentRefinement to boolean ([#2701](#2701)) ([db934fd](db934fd))
* **core:** searchState can be non-Object object ([#2722](#2722)) ([dea493c](dea493c)), closes [#2568](#2568)
* **createConnector:** new life cycles ([#2357](#2357)) ([fc10640](fc10640))
* **createInstantSearchManager:** do not trigger search on index update ([#2552](#2552)) ([e209362](e209362))
* **deps:** update dependency antd to v3.19.3 ([#2530](#2530)) ([73636c5](73636c5))
* **deps:** update dependency antd to v3.19.4 ([#2559](#2559)) ([c3e8267](c3e8267))
* **deps:** update dependency antd to v3.19.5 ([#2560](#2560)) ([72efd31](72efd31))
* **deps:** update dependency antd to v3.19.6 ([#2564](#2564)) ([654f986](654f986))
* **deps:** update dependency antd to v3.19.7 ([#2573](#2573)) ([7e963ad](7e963ad))
* **deps:** update dependency antd to v3.19.8 ([#2584](#2584)) ([34dd9b2](34dd9b2))
* **deps:** update dependency antd to v3.20.0 ([#2611](#2611)) ([b976c67](b976c67))
* **deps:** update dependency antd to v3.20.1 ([#2635](#2635)) ([792ad9c](792ad9c))
* **deps:** update dependency antd to v3.20.2 ([#2655](#2655)) ([301c2d8](301c2d8))
* **deps:** update dependency antd to v3.20.3 ([#2658](#2658)) ([d078e70](d078e70))
* **deps:** update dependency antd to v3.20.5 ([#2686](#2686)) ([42ef821](42ef821))
* **deps:** update dependency antd to v3.20.6 ([#2711](#2711)) ([927fbfe](927fbfe))
* **deps:** update dependency antd to v3.20.7 ([#2712](#2712)) ([1830952](1830952))
* **deps:** update dependency antd to v3.21.1 ([#2736](#2736)) ([39a51a6](39a51a6))
* **deps:** update dependency antd to v3.21.2 ([#2738](#2738)) ([a7a998a](a7a998a))
* **deps:** update dependency antd to v3.21.4 ([#2747](#2747)) ([60012be](60012be))
* **deps:** update dependency antd to v3.22.0 ([#2758](#2758)) ([9cda468](9cda468))
* **deps:** update dependency lodash to v4.17.13 ([c4974cf](c4974cf))
* **deps:** update dependency lodash to v4.17.14 ([#2647](#2647)) ([a2d2dd5](a2d2dd5))
* **deps:** update dependency lodash to v4.17.15 ([#2684](#2684)) ([354143f](354143f))
* **deps:** update dependency next to v9 ([#2638](#2638)) ([d22f61d](d22f61d))
* **deps:** update dependency next to v9.0.1 ([#2652](#2652)) ([2c2dab9](2c2dab9))
* **deps:** update dependency next to v9.0.2 ([#2662](#2662)) ([6fa4c5e](6fa4c5e))
* **deps:** update dependency next to v9.0.3 ([#2724](#2724)) ([f51b04b](f51b04b))
* **deps:** update dependency next to v9.0.4 ([#2767](#2767)) ([9af9180](9af9180))
* **deps:** update dependency qs to v6.8.0 ([#2757](#2757)) ([8bffb87](8bffb87))
* **deps:** update dependency react-compound-slider to v2.1.0 ([#2610](#2610)) ([3389ee5](3389ee5))
* **deps:** update dependency react-compound-slider to v2.2.0 ([#2649](#2649)) ([7b81af1](7b81af1))
* **deps:** update dependency react-native-vector-icons to v6.5.0 ([#2520](#2520)) ([5f7f5b6](5f7f5b6))
* **deps:** update dependency react-native-vector-icons to v6.6.0 ([#2599](#2599)) ([b6bb199](b6bb199))
* **deps:** update dependency react-router-dom to v5.0.1 ([#2506](#2506)) ([d762230](d762230))
* **geo:** check for undefined in isEqual ([#2643](#2643)) ([a544231](a544231)), closes [#2467](#2467)
* **geo:** remove lifecycle compat ([#2644](#2644)) ([2b2b898](2b2b898)), closes [#2626](#2626)
* **highlight:** switch to index as key ([#2690](#2690)) ([51de682](51de682))
* **highlight:** switch to index as key ([#2691](#2691)) ([17e75d1](17e75d1)), closes [#2688](#2688)
* **peerDependencies:** update React ([#2626](#2626)) ([6ccad49](6ccad49))
* **ssr:** avoid duplicate serializing ([#2726](#2726)) ([c768b1a](c768b1a))
* **voiceSearch:** fix incorrect status on stop ([#2535](#2535)) ([824dc22](824dc22))

### Code Refactoring

* **lodash:** get ([#2461](#2461)) ([527b879](527b879))
* **lodash:** has ([#2434](#2434)) ([75a4a15](75a4a15))

### Features

* **autocomplete:** add queryID & position to provided hits ([#2687](#2687)) ([e453dab](e453dab))
* **client:** remove algoliaClient, appId & apiKey ([#2338](#2338)) ([b84a0b5](b84a0b5))
* **context:** migrate to new React context ([#2178](#2178)) ([0a1abea](0a1abea)), closes [#2179](#2179) [#2180](#2180) [#2181](#2181) [#2185](#2185) [#2192](#2192) [#2189](#2189) [#2190](#2190) [#2179](#2179) [#2180](#2180) [#2181](#2181) [#2185](#2185) [#2192](#2192) [#2190](#2190)
* **ssr:** update the SSR API ([#2555](#2555)) ([925bdb8](925bdb8)), closes [#2536](#2536) [#2537](#2537)

### BREAKING CHANGES

* **lodash:** no longer do we allow paths like `attribute[5].something`, or other indexed forms, only `.` is allowed as special key.

All existing tests still pass, and we never documented you could use `lodash.get` patterns other than `.`.

* feat(get): accept array & bracked-separated string

moved to utils at the same time

* fix typo

* feedback: test for undefined behaviour

* chore(size): update expectation

this will go down afterwards, but for now there's some more duplication
* **lodash:** translation will render default value if passed undefined as value

* chore(lodash): remove imports

* fix(translation): allow undefined value to be passed on purpose
tkrugg added a commit that referenced this pull request Oct 18, 2019
* refactor(DOMMaps): use new React Context API (#2023)

* fix(maps): migrate to new React Context API

* refactor(maps): update context props to TypeScript

* refactor(maps): rename context types

* fix(maps): provide default context values

* fix(maps): remove `displayName`s

* test(maps): remove getStateContext function uses

* fix(maps): use React ref API

* fix(maps): update context usage

- Pass state from provider
- Pass context as props to children

* test(maps): implement Connected tests

* style(maps): lint files

* test(maps): test withGoogleMaps

* test(maps): update GoogleMaps tests

* fix(maps): set the state only once

* fix(maps): add ref to map element

* fix(maps): use static field for state

* test(maps): inline props in test

* fix(maps): use class field in Provider

* fix(maps): render provider when map is ready

* fix(maps): memoize values passed to context in Provider

* test(maps): test GoogleMaps context

* fix(maps): return undefined in GeoSearchContext

* revert: fix(maps): return undefined in GeoSearchContext

This reverts commit 3733602.

* chore(tslint): disable no-empty rule

* test(maps): inline props in Redo test

* fix(maps): apply changes

* fix(maps): cast default GoogleMapsContext values

* test(maps): test Provider mapValue reference

* fix(maps): add comment on GoogleMapsContext

* test(maps): update GoogleMaps tests

* feat(context): migrate to new React context (#2178)

This PR is quite long, but is split up in these steps

- [x] **STEP 1**: migrate createConnector (#2178, this PR)
- [x] **STEP 2**: first PR with connectors (searchbox, configure, hits, pagination) (#2179)
- [x] **STEP 3**: other connectors (#2180)
- [x] **STEP 4**: Multi index core (#2181)
- [x] **STEP 5**: Multi index connectors (#2185)
- [x] **STEP 6**: SSR (#2192)
- [ ] **STEP 7**: TypeScript completion (#2189) (merged later)
- [x] **STEP 8**: documentation change (#2190)

* feat(context): migrate core [STEP 1]

This includes:

1. change to createConnector
2. change to createStore
3. skip failing tests
4. small nits found while coding

After this to do:

STEP 2: first PR with connectors (searchbox, configure, hits, pagination)
STEP 3+: other connectors
STEP 4: Multi index core
STEP 5+: Multi index connectors
STEP 6: SSR
STEP 7: TypeScript completion
STEP 8: documentation change

* chore: remove context cache

* chore(tslint): add back accidentally removed prettier

* fix(connector): call gPP with correct "this"

* chore(TS): ReactType for Root

* test(connector): swap mount for shallow where possible

* chore(InstantSearch): refactor branch

* test(InstantSearch): avoid mutation

* chore(connector): remove unused

* chore(createConnector): warn on creation instead of mount

* fix(connector): remove unused variable

* chore(connector): consistent if

* chore(store): simplify typing

* chore(stories): better display name

* chore(TS): fix typing of results

* chore: remove useless comments

* consistent naming

* fix(InstantSearch): update index name when it changes

* prettier

* chore: remove old comment

* chore: fix merge

* ci: remove no-empty rule

* fix: make TS work in new connectors

* chore: fix bundlesize

* feedback from review (remove comments & warning)

* more review comments

* Update packages/react-instantsearch-core/src/components/InstantSearch.tsx

Co-Authored-By: Haroenv <fingebimus@me.com>

* feat(context): migrate base connector [STEP 2] (#2179)

* feat(context): migrate core [STEP 1]

This includes:

1. change to createConnector
2. change to createStore
3. skip failing tests
4. small nits found while coding

After this to do:

STEP 2: first PR with connectors (searchbox, configure, hits, pagination)
STEP 3+: other connectors
STEP 4: Multi index core
STEP 5+: Multi index connectors
STEP 6: SSR
STEP 7: TypeScript completion
STEP 8: documentation change

* feat(context): migrate base connector [STEP 2]

This is enough changes to be able to look at the storybook without errors again (only pagination, hits, searchbox of course, and nothing multi-index)

For full roadmap, see #2178

* test(configure): test with non-global this

* chore: from merge

* chore: updat bundle size

* chore: remove stuff from bad merge

* feedback from review

* feat(context): migrate remaining connectors [STEP 3] (#2180)

* feat(context): migrate remaining connectors [STEP 3]

chore: remove wrong import

test(currentRefinements): remove unused context

chore(range): fix typo

fix(geoSearch): gSP

test: call connectors with unique context where possible

feedback from review

chore(infiniteHits): cleaner test

refactor: migrate new connectors

chore: prettier

fix context

default props

fix TS

chore: small fix

* feat(context): multi-index [STEP 4] (#2181)

* feat(context): migrate remaining connectors [STEP 3]

* chore: remove wrong import

* test(currentRefinements): remove unused context

* chore(range): fix typo

* fix(geoSearch): gSP

* test: call connectors with unique context where possible

* feedback from review

* chore(infiniteHits): cleaner test

* refactor: migrate new connectors

* chore: prettier

* fix context

* default props

* fix TS

* chore: small fix

* feat(context): multi-index [STEP 4]

  test(Index): re-enable and make work

  fix(Index): allow context to be empty initially

  fix(Index): onSearchParameters with correct context

  fix(connector): onSearchParameters with correct context

  chore(Index): remove else

  chore(Index): consistent integration test

  chore: clarify test

  chore: fix life cycle

  fix(ts): index context can be undefined

  feedback from review

  fix(index): correct life cycles

  fix TS on Index

  connectorWrapper

  chore: update snapshots

* feat(context): apply multi-index [STEP 5] (#2185)

Co-Authored-By: samouss <samouss@users.noreply.github.com>

  * feat(context): modify Index to use modern context

  * test(Index): re-enable and make work

  * fix(Index): allow context to be empty initially

  * fix(Index): onSearchParameters with correct context

  * fix(connector): onSearchParameters with correct context

  * chore(Index): remove else

  * chore(Index): consistent integration test

  * chore: clarify test

  * chore: fix life cycle

  * fix(ts): index context can be undefined

  * feedback from review

  * fix(index): correct life cycles

  * fix TS on Index

  * connectorWrapper

  * chore: update snapshots

  * feat(context): modify Index to use modern context

  * feat(context): apply multi-index [STEP 5]

  1. connectMenu

  * connectAutoComplete

  * connectBreadcrumb

  * connectConfigure

  * connectGeoSearch

  * connectHierarchicalMenu

  * connectHits

  * connectHitsPerPage

  * connectInfiniteHits

  * connectNumericMenu

  * connectPagination

  * connectStats

  * connectRange

  * connectRefinementList

  * connectScrollTo

  * connectSearchBox

  * test(hierarchical): remove shadowing

  * connectSortBy

  * connectStateResults

  * connectToggleRefinement

  * fix(configure): use multi-index context

  * chore(configure): replace lodash.omit by spreading

  * test(connectors): call changing context

  * chore(configure): less lodash

  * test(configure): more detailed test

  * chore(test): rename ctx to instance

  * chore: move test

  * suggestions from review (mainly making multi-index tests more interesting)

  * chore: fix bundlesize

  * wrong conflict

  * migrate connectQueryRules

  * Feedback from review

  * fix(hitInsights): re-enable multi-index tests

* feat(context): re-enable SSR [STEP 6] (#2192)

  * chore(ssr): unskip tests

  * test(ssr): better test implem

  * chore: remove unused file

  * test: more consistent mock

* docs(connectors): fix spelling [STEP 8] (#2190)

  These are misc fixes in spelling that didn't exactly fit in a different PR

  remove small typo

* chore(context): migrate Panel (#2203)

* chore(context): migrate Panel

This migration is fairly straightforward, and has no impact on how the PanelCallbackHandler is used, although it adds a new component in that tree so it can read the context

IFW-485

* refactor(lodash): pick (#2432)

* refactor(lodash): pick

replaced by destructuring

* chore: remove isEmpty variable

* chore(utils): rename to TS

* chore(TS): rename dom utils

* chore(TS): add minor types to dom utils

* chore(TS): ignore lint rule

* refactor(lodash): range (#2444)

IFW-739

* fix(createConnector): new life cycles (#2357)

* fix(createConnector): new life cycles

- move willMount -> constructor
- move willReceiveProps -> didUpdate

This didn't have an impact on more requests, but did cause one more render if you update a prop

IFW-671

* remove comment

* test(sCU): shouldComponentUpdate is called two separate times now

* refactor(lodash): remove fill (#2454)

I replaced this by the `range` utility merged earlier, since it's basically what was needed here.

IFW-741

* refactor(lodash): remove difference (#2455)

Both are arrays & always defined, so it's really enough to find all props in this._props (prevProps), but not in `props`

* refactor(lodash): remove zipWith (#2459)

* refactor(lodash): remove zipWith

IFW-737

* chore: add comment back

* refactor(lodash): replace isFinite (#2458)

* refactor(lodash): replace isFinite

lodash.isFinite is just `typeof value == 'number' && nativeIsFinite(value);`, so that's what I implemented

IFW-745

* chore: remove needless typeof

* refactor(lodash): isPlainObject (#2460)

* refactor(lodash): isPlainObject

The values this function was used for seemed like they can only be arrays or objects to me.

We will only want to empty out "breadth-first", so empty objects will stay in the output if they became empty because of the function itself.

isEmpty here is removed in #2442, and still works the same (but will need a rebase)

The newly added tests also pass with the previous implementation

The function is only used in `onSearchStateChange` as a response to a `cleanUp` (caused by unmount) on a widget

IFW-743

* test: remove only

* chore(ts): use `unknown`

* refactor(lodash): replace find (#2446)

Chosen to duplicate the funciton in core & dom, because we have no good way to share functionality otherwise

IFW-740

* refactor(lodash): has (#2434)

* refactor(lodash): has

replace mostly by item[key] === undefined, which isn't completely the same, but close enough in our case, since rendering undefined would be quite weird.

BREAKING CHANGE:
translation will render default value if passed undefined as value

* chore(lodash): remove imports

* fix(translation): allow undefined value to be passed on purpose

*  refactor(lodash): replace isEqual (#2467)

* refactor(lodash): replace isEqual

1. specified function for maps

IFW-735

* refactor(lodash): replace isEqual with fast-deep-equal

* refactor(lodash): replace omit (#2466)

* refactor(lodash): omit (dom)

In this case, you can simply override a prop, which will take preference, like in any other object.

* refactor(omit): use internal (babel) replacement

* refactor(omit): use destructuring replacement

* refactor(indexUtils): use new omit where possible

* refactor(indexutils): remove omit with path

* chore: fix merge

* chore(size): update

* chore(life cycle): add comments where change is necessary

* fix(compat): upgrade SearchBox lifecycle (#2288)

* fix(compat): upgrade RangeSlider lifecycle (#2290)

* fix(compat): upgrade RangeInput lifecycle (#2289)

* fix(compat): upgrade Tourism example lifecycles (#2305)

* feat(client): remove algoliaClient, appId & apiKey (#2338)

* feat(client): remove algoliaClient alias

* chore(error): remove duplicate colon

* docs(examples): use searchClient everywhere

* feat(searchClient): remove other options

* adds back user agent tests & remove defaultAlgoliaClient

* remove algoliasearch from dependencies

* remove algoliasearch usage

* chore: update max size

* fix(propTypes): more strict searchClient type

* chore(examples): add algoliasearch as dependency

* chore(stories): memoize search client

* chore: update proptype

* refactor(lodash): get (#2461)

* refactor(lodash): get

IFW-742

BREAKING CHANGE: no longer do we allow paths like `attribute[5].something`, or other indexed forms, only `.` is allowed as special key.

All existing tests still pass, and we never documented you could use `lodash.get` patterns other than `.`.

* feat(get): accept array & bracked-separated string

moved to utils at the same time

* fix typo

* feedback: test for undefined behaviour

* chore(size): update expectation

this will go down afterwards, but for now there's some more duplication

* refactor(lodash): isEmpty (#2442)

* refactor(lodash): isEmpty

reusing objectHasKeys strategy from the helper

IFW-736

* refactor(lodash): remove isEmpty from server

* chore(TS): clearer type

* feedback: don't use objectHasKeys for array

* fix implementation

* refactor(example): remove lodash

* fix(numeric): correct reimplementation of !isEmpty

* chore(size): update expectation

somewhat bigger for now, but in the long run it'll shrink

* fix(compat): upgrade React Router example lifecycles (#2307)

* fix(compat): upgrade React Router v3 example lifecycles (#2314)

* fix(compat): upgrade React Native example and its lifecycles (#2304)

* fix(compat): upgrade Next.js example lifecycles (#2379)

* fix(compat): update Next example

* fix(compat): use last Next router

* fix(createInstantSearchManager): do not trigger search on index update (#2552)

* fix(createInstantSearchManager): do not trigger search on index update

* fix(createInstantSearchManager): add comment in updateIndex

* feat(ssr): update the SSR API (#2555)

* feat(ssr): only expose findResultsState [PART-1] (#2536)

* feat(ssr): hydrate client [PART-2] (#2537)

* feat(ssr): update usage of the API [PART-3]

* refactor(root): remove createIndex & createInstantSearch (#2339)

* refactor(InstantSearch): migrate life cycles (#2349)

*  fix(createInstantSearchManager): fix multi-index search  (#2570)

* fix(createInstantSearchManager): fix multi-index search

* Fix tests

* Update bundlesize

* Map indexName prop to indexId when indexId is not defined

* Add tests

* Pass indexName through variable for clarity

* Simplify test

* Simplify other tests

* refactor(lodash): orderBy (#2462)

* refactor(lodash): orderBy

The utility is copied from the helper (which passed all lodash tests), I put it inline in the connector, since it's not used in any other spot.

IFW-746

* refactor(menu): remove orderBy & use helper method

These tests provide no security at all, but this change in behaviour can be confirmed in the stories.

* chore(indexUtils): make usage simpler

I caught this when trying to refactor the tests to use a real helper, but eventually decided not to do that

* chore: update test name

* chore: different if style

* chore(test): simplify

* chore: update sizes

* chore(size): looser limit

* simplify code

* chore: update bundlesize

* chore(lint): remove wrong merges

* chore(react-native): roll back react version

* chore(lint): small fix

* chore(ssr): fix example build

* chore(lodash): remove dependencies (#2600)

- lodash from packages
- babel-plugin-lodash from root
- swap out isEqual from connectInfiniteHits

IFW-778

closes #2468

* fix(peerDependencies): update React (#2626)

* fix(peerDependencies): update React

We are now relying on React 16.3 features like `static getDerivedStateFromProps` in the library, which thus won't work with lower versions.

The lowest version of React Native which requires React 16.3 (albeit an alpha) is 0.54.0.

* !fixup

* refactor(helper): replace Helper usage (#2621)

* docs(MIGRATION): migrate to v6 (#2627)

* docs(MIGRATION): migrate to v6

* docs(MIGRATION): update wording

Co-Authored-By: Haroen Viaene <fingebimus@me.com>
Co-Authored-By: François Chalifour <francoischalifour@users.noreply.github.com>

* docs(MIGRATION): add snippet for appID & apiKey

* docs(MIGRATION): add algoliasearchHelper section

* fix(geo): remove lifecycle compat (#2644)

This is no longer necessary, since we now require React 16.3 as a peer dependency (#2626)

* docs(stories): remove stories whoich highlight a custom root (#2645)

This has been removed in #2339, so no longer works (nor necessary)

* fix(geo): check for undefined in isEqual (#2643)

issue introduced in #2467

IFW-851

* fix(highlight): switch to index as key (#2690)

the reason is that the full value could be duplicate, so we added the index; but the index can't be duplicate within the list.

* feat(autocomplete): add queryID & position to provided hits (#2687)

* feat(autocomplete): add queryID to provided hits if defined

This was accidentally forgotten when we added the queryID to hits & infinite hits.

IFW-902

* feat(autocomplete): add absolute position too

* Update packages/react-instantsearch-core/src/connectors/__tests__/connectAutoComplete.js

* fix(core): searchState can be non-Object object (#2722)

* fix(core): searchState can be non-Object object

If someone calls `Object.create(null)` and then adds the expected properties, `hasOwnProperty` will not be available on the object itself. 

fixes #2568

* fix(ssr): avoid duplicate serializing (#2726)

* fix(ssr): avoid duplicate serializing

Response of `findResultsState` (and `resultsState` prop) before:

```js
const resultsState = {
  content: SearchResults(state: searchParameters, results: rawResults),
  state: searchParameters,
  _originalResponse: {
    results: rawResults
  },
};
```

Note that `SearchResults` has the properties `_rawResults` & `_state`. This means that when we serialize, we are retrieving the original response and state twice.

Then on further searching, I also find that we don't need to serialize the `SearchResults` object at all, since only the raw response and state is used.

I modified this to be more consistent and no longer have duplication:

```js
const resultsState = {
  state: searchParameters,
  rawResults,
};
```

The `SearchParameters` object gets serialized without issue, as before.

This change in shape has of course also an impact on the shape of `resultsState`, the prop, but that is fine, since it was previously typed as `any`.

To be able to type it correctly, I had to add `@types/algoliasearch` & update `algoliasearch-helper` for typescript though.

This was initially noticed by @cloakedninjas, thanks!

* empty commit for CI

* chore: fix linting for next

* chore: fix lint again 🤔

* chore(examples): downgrade react in rn example

* v6.0.0-beta.0

# [6.0.0-beta.0](v5.7.0...v6.0.0-beta.0) (2019-08-21)

### Bug Fixes

* **compat:** upgrade Next.js example lifecycles ([#2379](#2379)) ([45939bc](45939bc))
* **compat:** upgrade RangeInput lifecycle ([#2289](#2289)) ([110b1af](110b1af))
* **compat:** upgrade RangeSlider lifecycle ([#2290](#2290)) ([69a7f53](69a7f53))
* **compat:** upgrade React Native example and its lifecycles ([#2304](#2304)) ([f390c17](f390c17))
* **compat:** upgrade React Router example lifecycles ([#2307](#2307)) ([ab828b0](ab828b0))
* **compat:** upgrade React Router v3 example lifecycles ([#2314](#2314)) ([3647154](3647154))
* **compat:** upgrade SearchBox lifecycle ([#2288](#2288)) ([c3ba42d](c3ba42d))
* **compat:** upgrade Tourism example lifecycles ([#2305](#2305)) ([fff5aa6](fff5aa6))
* **connectToggleRefinement:** cast currentRefinement to boolean ([#2701](#2701)) ([db934fd](db934fd))
* **core:** searchState can be non-Object object ([#2722](#2722)) ([dea493c](dea493c)), closes [#2568](#2568)
* **createConnector:** new life cycles ([#2357](#2357)) ([fc10640](fc10640))
* **createInstantSearchManager:** do not trigger search on index update ([#2552](#2552)) ([e209362](e209362))
* **deps:** update dependency antd to v3.19.3 ([#2530](#2530)) ([73636c5](73636c5))
* **deps:** update dependency antd to v3.19.4 ([#2559](#2559)) ([c3e8267](c3e8267))
* **deps:** update dependency antd to v3.19.5 ([#2560](#2560)) ([72efd31](72efd31))
* **deps:** update dependency antd to v3.19.6 ([#2564](#2564)) ([654f986](654f986))
* **deps:** update dependency antd to v3.19.7 ([#2573](#2573)) ([7e963ad](7e963ad))
* **deps:** update dependency antd to v3.19.8 ([#2584](#2584)) ([34dd9b2](34dd9b2))
* **deps:** update dependency antd to v3.20.0 ([#2611](#2611)) ([b976c67](b976c67))
* **deps:** update dependency antd to v3.20.1 ([#2635](#2635)) ([792ad9c](792ad9c))
* **deps:** update dependency antd to v3.20.2 ([#2655](#2655)) ([301c2d8](301c2d8))
* **deps:** update dependency antd to v3.20.3 ([#2658](#2658)) ([d078e70](d078e70))
* **deps:** update dependency antd to v3.20.5 ([#2686](#2686)) ([42ef821](42ef821))
* **deps:** update dependency antd to v3.20.6 ([#2711](#2711)) ([927fbfe](927fbfe))
* **deps:** update dependency antd to v3.20.7 ([#2712](#2712)) ([1830952](1830952))
* **deps:** update dependency antd to v3.21.1 ([#2736](#2736)) ([39a51a6](39a51a6))
* **deps:** update dependency antd to v3.21.2 ([#2738](#2738)) ([a7a998a](a7a998a))
* **deps:** update dependency antd to v3.21.4 ([#2747](#2747)) ([60012be](60012be))
* **deps:** update dependency antd to v3.22.0 ([#2758](#2758)) ([9cda468](9cda468))
* **deps:** update dependency lodash to v4.17.13 ([c4974cf](c4974cf))
* **deps:** update dependency lodash to v4.17.14 ([#2647](#2647)) ([a2d2dd5](a2d2dd5))
* **deps:** update dependency lodash to v4.17.15 ([#2684](#2684)) ([354143f](354143f))
* **deps:** update dependency next to v9 ([#2638](#2638)) ([d22f61d](d22f61d))
* **deps:** update dependency next to v9.0.1 ([#2652](#2652)) ([2c2dab9](2c2dab9))
* **deps:** update dependency next to v9.0.2 ([#2662](#2662)) ([6fa4c5e](6fa4c5e))
* **deps:** update dependency next to v9.0.3 ([#2724](#2724)) ([f51b04b](f51b04b))
* **deps:** update dependency next to v9.0.4 ([#2767](#2767)) ([9af9180](9af9180))
* **deps:** update dependency qs to v6.8.0 ([#2757](#2757)) ([8bffb87](8bffb87))
* **deps:** update dependency react-compound-slider to v2.1.0 ([#2610](#2610)) ([3389ee5](3389ee5))
* **deps:** update dependency react-compound-slider to v2.2.0 ([#2649](#2649)) ([7b81af1](7b81af1))
* **deps:** update dependency react-native-vector-icons to v6.5.0 ([#2520](#2520)) ([5f7f5b6](5f7f5b6))
* **deps:** update dependency react-native-vector-icons to v6.6.0 ([#2599](#2599)) ([b6bb199](b6bb199))
* **deps:** update dependency react-router-dom to v5.0.1 ([#2506](#2506)) ([d762230](d762230))
* **geo:** check for undefined in isEqual ([#2643](#2643)) ([a544231](a544231)), closes [#2467](#2467)
* **geo:** remove lifecycle compat ([#2644](#2644)) ([2b2b898](2b2b898)), closes [#2626](#2626)
* **highlight:** switch to index as key ([#2690](#2690)) ([51de682](51de682))
* **highlight:** switch to index as key ([#2691](#2691)) ([17e75d1](17e75d1)), closes [#2688](#2688)
* **peerDependencies:** update React ([#2626](#2626)) ([6ccad49](6ccad49))
* **ssr:** avoid duplicate serializing ([#2726](#2726)) ([c768b1a](c768b1a))
* **voiceSearch:** fix incorrect status on stop ([#2535](#2535)) ([824dc22](824dc22))

### Code Refactoring

* **lodash:** get ([#2461](#2461)) ([527b879](527b879))
* **lodash:** has ([#2434](#2434)) ([75a4a15](75a4a15))

### Features

* **autocomplete:** add queryID & position to provided hits ([#2687](#2687)) ([e453dab](e453dab))
* **client:** remove algoliaClient, appId & apiKey ([#2338](#2338)) ([b84a0b5](b84a0b5))
* **context:** migrate to new React context ([#2178](#2178)) ([0a1abea](0a1abea)), closes [#2179](#2179) [#2180](#2180) [#2181](#2181) [#2185](#2185) [#2192](#2192) [#2189](#2189) [#2190](#2190) [#2179](#2179) [#2180](#2180) [#2181](#2181) [#2185](#2185) [#2192](#2192) [#2190](#2190)
* **ssr:** update the SSR API ([#2555](#2555)) ([925bdb8](925bdb8)), closes [#2536](#2536) [#2537](#2537)

### BREAKING CHANGES

* **lodash:** no longer do we allow paths like `attribute[5].something`, or other indexed forms, only `.` is allowed as special key.

All existing tests still pass, and we never documented you could use `lodash.get` patterns other than `.`.

* feat(get): accept array & bracked-separated string

moved to utils at the same time

* fix typo

* feedback: test for undefined behaviour

* chore(size): update expectation

this will go down afterwards, but for now there's some more duplication
* **lodash:** translation will render default value if passed undefined as value

* chore(lodash): remove imports

* fix(translation): allow undefined value to be passed on purpose

* chore(deps): update examples to react-instantsearch v6.0.0-beta.0

* chore(index): don't require `indexId` on `IndexWrapper` (#2834)

* Don't require `indexId` proptype on Index widget wrapper

* Use unique type for IndexWrapper props

* merge branch master into next

* test(examples): update snapshots (#2845)

* fix(ssr): add error when no indexName is passed (#2842)

* fix(InstantSearch): update the searchState on props update (#2852)

**Summary**

This PR fixes an issue where an infinite loop occurs with the controlled mode. The update of the `searchState` was done too late. With V5 the update was done inside `cWRP` but with V6 we move the update inside `cDU`. This change has an impact on when the `searchState` is updated. With `cWRP` it was executed before the `render` of the children, it's not the case anymore with `cDU`. It's done after.

Those children can read the `searchState` provided by the manager. When it's not up to date they alter the previous version of the state. With an `onSearchStateChange` function that relies on the value of `searchState` to add remove parameters, it can lead to infinite loop because the props are changes/reverted at each render.

The fix uses `getDerivedStateFromProps` to keep the `searchState` up to date. The issue with this solution (on V5 too) is that we might trigger one useless request when the props change. It's because the update and the search are tied together inside `onExternalStateUpdate`. One solution to this would be to decouple the two. Apply the `searchState` update as soon as possible but trigger the search on `cDU` once we've computed the state from the children.

**Before**

![before](https://user-images.githubusercontent.com/6513513/66131368-9c15d180-e5f3-11e9-9aad-c46ea6fca340.gif)

**After**

![after](https://user-images.githubusercontent.com/6513513/66131378-9f10c200-e5f3-11e9-8980-e6a6e5d626a4.gif)

* refactor(example): remove usage of aroundLatLng (#2853)

**Summary**

This PR removes the usage of `aroundLatLng` inside the geo-search example. The logic to apply the parameter was present, but the App doesn't expose a way to use it. We don't have to support it since it uses either the IP of the user of the bounding box of the map.
tkrugg added a commit that referenced this pull request Oct 18, 2019
# [6.0.0-beta.1](v5.7.0...v6.0.0-beta.1) (2019-10-18)

### Bug Fixes

* **connectToggleRefinement:** cast currentRefinement to boolean ([#2701](#2701)) ([db934fd](db934fd))
* **deps:** update dependency antd to v3.19.3 ([#2530](#2530)) ([73636c5](73636c5))
* **deps:** update dependency antd to v3.19.4 ([#2559](#2559)) ([c3e8267](c3e8267))
* **deps:** update dependency antd to v3.19.5 ([#2560](#2560)) ([72efd31](72efd31))
* **deps:** update dependency antd to v3.19.6 ([#2564](#2564)) ([654f986](654f986))
* **deps:** update dependency antd to v3.19.7 ([#2573](#2573)) ([7e963ad](7e963ad))
* **deps:** update dependency antd to v3.19.8 ([#2584](#2584)) ([34dd9b2](34dd9b2))
* **deps:** update dependency antd to v3.20.0 ([#2611](#2611)) ([b976c67](b976c67))
* **deps:** update dependency antd to v3.20.1 ([#2635](#2635)) ([792ad9c](792ad9c))
* **deps:** update dependency antd to v3.20.2 ([#2655](#2655)) ([301c2d8](301c2d8))
* **deps:** update dependency antd to v3.20.3 ([#2658](#2658)) ([d078e70](d078e70))
* **deps:** update dependency antd to v3.20.5 ([#2686](#2686)) ([42ef821](42ef821))
* **deps:** update dependency antd to v3.20.6 ([#2711](#2711)) ([927fbfe](927fbfe))
* **deps:** update dependency antd to v3.20.7 ([#2712](#2712)) ([1830952](1830952))
* **deps:** update dependency antd to v3.21.1 ([#2736](#2736)) ([39a51a6](39a51a6))
* **deps:** update dependency antd to v3.21.2 ([#2738](#2738)) ([a7a998a](a7a998a))
* **deps:** update dependency antd to v3.21.4 ([#2747](#2747)) ([60012be](60012be))
* **deps:** update dependency antd to v3.22.0 ([#2758](#2758)) ([9cda468](9cda468))
* **deps:** update dependency antd to v3.22.2 ([#2791](#2791)) ([ff1f5d9](ff1f5d9))
* **deps:** update dependency antd to v3.23.2 ([#2814](#2814)) ([a190410](a190410))
* **deps:** update dependency lodash to v4.17.13 ([c4974cf](c4974cf))
* **deps:** update dependency lodash to v4.17.14 ([#2647](#2647)) ([a2d2dd5](a2d2dd5))
* **deps:** update dependency lodash to v4.17.15 ([#2684](#2684)) ([354143f](354143f))
* **deps:** update dependency next to v9 ([#2638](#2638)) ([d22f61d](d22f61d))
* **deps:** update dependency next to v9.0.1 ([#2652](#2652)) ([2c2dab9](2c2dab9))
* **deps:** update dependency next to v9.0.2 ([#2662](#2662)) ([6fa4c5e](6fa4c5e))
* **deps:** update dependency next to v9.0.3 ([#2724](#2724)) ([f51b04b](f51b04b))
* **deps:** update dependency next to v9.0.4 ([#2767](#2767)) ([9af9180](9af9180))
* **deps:** update dependency next to v9.0.5 ([#2789](#2789)) ([0a75f41](0a75f41))
* **deps:** update dependency qs to v6.8.0 ([#2757](#2757)) ([8bffb87](8bffb87))
* **deps:** update dependency react-compound-slider to v2.1.0 ([#2610](#2610)) ([3389ee5](3389ee5))
* **deps:** update dependency react-compound-slider to v2.2.0 ([#2649](#2649)) ([7b81af1](7b81af1))
* **deps:** update dependency react-native-vector-icons to v6.5.0 ([#2520](#2520)) ([5f7f5b6](5f7f5b6))
* **deps:** update dependency react-native-vector-icons to v6.6.0 ([#2599](#2599)) ([b6bb199](b6bb199))
* **deps:** update dependency react-router-dom to v5.0.1 ([#2506](#2506)) ([d762230](d762230))
* **highlight:** switch to index as key ([#2691](#2691)) ([17e75d1](17e75d1)), closes [#2688](#2688)
* **voiceSearch:** fix incorrect status on stop ([#2535](#2535)) ([824dc22](824dc22))

### chore

* **release:** 6.0.0-beta.1 ([#2861](#2861)) ([cb56ca0](cb56ca0)), closes [#2023](#2023) [#2178](#2178) [#2178](#2178) [#2179](#2179) [#2180](#2180) [#2181](#2181) [#2185](#2185) [#2192](#2192) [#2189](#2189) [#2190](#2190) [#2179](#2179) [#2178](#2178) [#2180](#2180) [#2181](#2181) [#2185](#2185) [#2192](#2192) [#2190](#2190) [#2203](#2203) [#2432](#2432) [#2444](#2444) [#2357](#2357) [#2454](#2454) [#2455](#2455) [#2459](#2459) [#2458](#2458) [#2460](#2460) [#2442](#2442) [#2446](#2446) [#2434](#2434) [#2467](#2467) [#2466](#2466) [#2288](#2288) [#2290](#2290) [#2289](#2289) [#2305](#2305) [#2338](#2338) [#2461](#2461) [#2442](#2442) [#2307](#2307) [#2314](#2314) [#2304](#2304) [#2379](#2379) [#2552](#2552) [#2555](#2555) [#2536](#2536) [#2537](#2537) [#2339](#2339) [#2349](#2349) [#2570](#2570) [#2462](#2462) [#2600](#2600) [#2468](#2468) [#2626](#2626) [#2621](#2621) [#2627](#2627) [#2644](#2644) [#2626](#2626) [#2645](#2645) [#2339](#2339) [#2643](#2643) [#2467](#2467) [#2690](#2690) [#2687](#2687) [#2722](#2722) [#2568](#2568) [#2726](#2726) [#2379](#2379) [#2289](#2289) [#2290](#2290) [#2304](#2304) [#2307](#2307) [#2314](#2314) [#2288](#2288) [#2305](#2305) [#2701](#2701) [#2568](#2568) [#2357](#2357) [#2552](#2552) [#2530](#2530) [#2559](#2559) [#2560](#2560) [#2564](#2564) [#2573](#2573) [#2584](#2584) [#2611](#2611) [#2635](#2635) [#2655](#2655) [#2658](#2658) [#2686](#2686) [#2711](#2711) [#2712](#2712) [#2736](#2736) [#2738](#2738) [#2747](#2747) [#2758](#2758) [#2647](#2647) [#2684](#2684) [#2638](#2638) [#2652](#2652) [#2662](#2662) [#2724](#2724) [#2767](#2767) [#2757](#2757) [#2610](#2610) [#2649](#2649) [#2520](#2520) [#2599](#2599) [#2506](#2506) [#2467](#2467) [#2626](#2626) [#2690](#2690) [#2688](#2688) [#2626](#2626) [#2726](#2726) [#2535](#2535) [#2461](#2461) [#2434](#2434) [#2687](#2687) [#2338](#2338) [#2179](#2179) [#2180](#2180) [#2181](#2181) [#2185](#2185) [#2192](#2192) [#2189](#2189) [#2190](#2190) [#2179](#2179) [#2180](#2180) [#2181](#2181) [#2185](#2185) [#2192](#2192) [#2190](#2190) [#2536](#2536) [#2537](#2537) [#2834](#2834) [#2845](#2845) [#2842](#2842) [#2852](#2852) [#2853](#2853)

### BREAKING CHANGES

* **release:** translation will render default value if passed undefined as value

* chore(lodash): remove imports

* fix(translation): allow undefined value to be passed on purpose
* **release:** no longer do we allow paths like `attribute[5].something`, or other indexed forms, only `.` is allowed as special key.

All existing tests still pass, and we never documented you could use `lodash.get` patterns other than `.`.

* feat(get): accept array & bracked-separated string

moved to utils at the same time

* fix typo

* feedback: test for undefined behaviour

* chore(size): update expectation

this will go down afterwards, but for now there's some more duplication
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants