Skip to content

"Can't perform a React state update on a component that hasn't mounted yet. This indicates that you have a side-effect in your render function that asynchronously later calls tries to update the component. Move this work to useEffect instead."Β #6428

@Ra0R

Description

@Ra0R

πŸ› Current behavior

When using InstantSearchNext ("react-instantsearch-nextjs": "0.3.17"), and β–² NextJs 14.2.17 switching from one page that has InstantSearchNext-Component to another will throw an error.

Error: Warning: Can't perform a React state update on a component that hasn't mounted yet. This indicates that you have a side-effect in your render function that asynchronously later calls tries to update the component. Move this work to useEffect instead. Hits@webpack-internal:///(app-pages-browser)/./node_modules/react-instantsearch/dist/es/widgets/Hits.js:31:20 div div Content InstantSearch@webpack-internal:///(app-pages-browser)/./node_modules/react-instantsearch-core/dist/es/components/InstantSearch.js:17:18 InstantSearchSSRProvider@webpack-internal:///(app-pages-browser)/./node_modules/react-instantsearch-core/dist/es/components/InstantSearchSSRProvider.js:23:18 InstantSearchNext@webpack-internal:///(app-pages-browser)/./node_modules/react-instantsearch-nextjs/dist/es/InstantSearchNext.js:30:18 div div Search Page (Server) InnerLayoutRouter@webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/layout-router.js:244:18 RedirectErrorBoundary@webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:74:9 RedirectBoundary@webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/redirect-boundary.js:82:24 NotFoundBoundary@webpack-internal:///(app-pages-browser)/./node_modules/next/dist/client/components/not-found-boundary.js:84:62 ....

πŸ” Steps to reproduce

  • Click link to open search
  • Open console
  • Enter something into the search box
  • Quickly switch to /page2

Live reproduction

https://codesandbox.io/p/github/Ra0R/bug-repro/master

πŸ’­ Expected behavior

Should not throw an error. Probably there is some useEffect firing that tries to update the component before mounting.

Package version

"react-instantsearch": "^7.13.7", "react-instantsearch-nextjs": "^0.3.17"

Operating system

No response

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageIssues to be categorized by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions