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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read property 'state' of null #6073
Comments
If I read the stack trace correctly, that would be related to instantsearch/packages/instantsearch.js/src/widgets/index/index.ts Lines 678 to 692 in 2258d89
helper would be null, but I imagine the index widget unmounts before init is ever called? In which case we probably should do less work.
Do you have any more information at all as to when this happens? Are there any unstable references maybe that could cause a remount of an index widget? What widgets do you have mounted, is anything conditional? Most likely I'd say this is happening on a quick page navigation, or a similar situation in which InstantSearch no longer will be mounted after the error, making the situation less "problematic", but I'm definitely not sure. |
From what I can see in my code we only use the react-instantsearch-core lib with the hook: useSearchBox in a rather classic way. If we look in a little more detail at the stack trace it looks like it goes from react-instantsearch-core to instentsearch.js |
I'd say this probably happens in the unmounting phase / navigating. Can you reproduce the error then @TristanMaurier98 ? |
I'm having great difficulty reproducing the bug but the project I'm working on is open source, here is the link to the file which I think is the cause of the problem. |
We've been experiencing this same issue, but only when we're using the To get around it for now, I installed
|
Are you also using React Native @MikeIbberson? Maybe that could be a common thread (although I still don't see the link, sorry!)? If someone could get a live stack trace, sentry, or when it happens a sort of reproduction, that would be the way to go to find the root cause. In the very least, I guess what we can do is first check if the index widget's One thing I think may be possible in the app, especially linked to @TristanMaurier98 is that maybe netInfo flickers on/off and the initial state is "enabled", then InstantSearch mounts, but immediately after it's "disabled" and InstantSearch unmounts, before the child widgets properly have mounted. |
We're using React 18 (JS not native). We're also using the latest versions of all Algolia packages, though I tried downgrading to releases from last year and observed the same issues. I will provide more context next week, as there's more development I need to do on this feature and can start building a case. Some things I've noted so far, though, anecdotally:
I'll provide proper code snippets as we dig into this more next week, but that's some initial information on what's going on. |
I have try to reproduce by flicking the netinfo but nothing happen (in ios, android and web). |
Current I'm using the
The error message:
|
I have the same problem in my NextJS application when using multi indices and widget : index.js:513 Uncaught TypeError: Cannot read properties of null (reading 'state') Using @sangdth solution (using InstantSearch component instead of InstantSearchNext component) removes the error. |
Hi, I've made a pull request #6173 that should fix this issue, feel free to try it out and give feedback! |
馃悰 Current behavior
On the sentry of our production app we have this error arriving, it seems to produce crashes but impossible to reproduce locally:
TypeError: Cannot read property 'state' of null
at anonymous(node_modules/instantsearch.js/cjs/widgets/index/index.js:447:26)
at forEach(native)
at dispose(node_modules/instantsearch.js/cjs/widgets/index/index.js:437:27)
at anonymous(node_modules/instantsearch.js/cjs/widgets/index/index.js:219:36)
at reduce(native)
at removeWidgets(node_modules/instantsearch.js/cjs/widgets/index/index.js:217:40)
at anonymous(node_modules/react-instantsearch-core/dist/cjs/lib/useWidget.js:74:36)
at anonymous(node_modules/react-instantsearch-core/dist/cjs/lib/useInstantSearchApi.js:47:19)
at forEach(native)
at anonymous(node_modules/react-instantsearch-core/dist/cjs/lib/useInstantSearchApi.js:46:39)
at apply(native)
at anonymous(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:213:23)
at _callTimer(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:111:15)
at callTimers(node_modules/react-native/Libraries/Core/Timers/JSTimers.js:359:17)
at apply(native)
at __callFunction(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:427:32)
at anonymous(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:113:26)
at __guard(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:368:11)
at callFunctionReturnFlushedQueue(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:17)
For more context we are running 脿 cross platform react-native app, and this error seems to appears at least on ios and android.
馃攳 Steps to reproduce
I don't have any, I would be more than glad to share more information.
Live reproduction
/
馃挱 Expected behavior
Not having this crashes.
Package version
"instantsearch.js": "^4.57.0", "react-instantsearch": "^7.0.0", "react-instantsearch-core": "^7.1.0",
Operating system
No response
Browser
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: