-
Notifications
You must be signed in to change notification settings - Fork 220
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Invalid hook call. Hooks can only be called inside of the body of a function component" when using ChatList and MessageList components #165
Comments
I see. I'm not sure why is not working on my side. I installed the libraries to their latest version. Maybe I need to reinstall the packages and try again. I'll let you know if I already solved the issue. Thanks! |
Hi @emregudur ! I still received the same error above after I reinstalled all the libraries on the project. And I noticed that when I run Do you think it is fall under warning number 1? |
Same on my side just like @wnmolit. |
Good relief. I thought I'm the only one receiving this error XD I tried to convert all of my class components into functional components, but still the same error. I think the problem is the version of react-dom from react-chat-elements. |
Hi guys, i published for [email protected]. Can you try again on react-chat-elements latest version? |
Hi @emregudur, Below is my code: ` export let Chat = (props) => {
}; My package.json looks like this: "dependencies": { I also have deleted npm_modules folder, and package-lock files several times. |
Still same error. All of my class components are converted to functional components and the libraries are all updated to latest version (react and react-dom 17.0.2) My codes are the same as above. |
Looks like the culprit is packge.json in react-chat-elements: "react-icons": "^2.2.5", react-icons v2.2.5 requires react v 16.x. react-icons requires an update to latest version i.e. 4.3.1 any version above 2.2.5 which requires react 17. |
Ok guys, I have some good news, the issue is with the module when installed via npm, if I use yarn, I am able to install and run it, more invalid hook errors when used yarn. what I did was:
"start": "react-scripts start", with "start": "GENERATE_SOURCEMAP=false react-scripts start", PS: THOUGH THIS SHOULD NOT BE NEEDED, BUT THAT IS HOW MY CURRENT PACKAGE.JSON LOOKS LIKE
|
I'm getting the same issue ( Has anyone been able to solve this, except for using yarn? |
@NathanC You should try yarn instead of npm. Please refer to the steps above, in my previous comment. |
Hi, we works on typescript-migration branch. And also we trying migrate to typescript this project. On this branch updated all dependencies for lastest react version. I believe to these works fix to this issue too. |
Is there any way to get this to work via npm? Tried various versions and getting the same error as others have noted. Haven't tried yarn yet. EDIT: I have tried the solution posted by @vahid-neuralinc and it seems like it does work now (thank you so much by the way). I have tested MessageList component by using the readme.md example |
I got an error after installing the latest version of this library.
I have the following packages:
"react-chat-elements": "^11.0.0"
"react": "^17.0.2"
"react-dom": "^17.0.2"
"next": "^12.0.1"
Here is my functional component:
Full stack error, in case you need:
The text was updated successfully, but these errors were encountered: