Invalid Hook Call - React Testing
See original GitHub issueI’m trying to test out the chat widget on a Gatsby site using it as a react component, however I keep getting this error, https://reactjs.org/docs/error-decoder.html/?invariant=321
I’m not sure what I’m doing wrong but the general idea was having a component like so:
import React, { Component } from 'react'
import { Widget } from 'rasa-webchat'
class WChat extends Component {
buildChat = () => {
return (
<Widget
initPayload={"/help"}
socketUrl={"http://example.com"}
socketPath={"/socket.io/"}
title={"Nerdy Chat"}
inputTextFieldHint={"Type a message..."}
connectingText={"Waiting for server..."}
embedded={true}
params={{
images: {
dims: {
width: 300,
height: 200
}
},
storage: "local"
}}
/>
)
}
render() {
return (
<div className="webchat-container" >
{this.buildChat()}
</div>
)
}
}
export default WChat;
Then I just reference this in my main index.js file as a component to try and load it, any idea what I’m doing wrong or why I’m hitting this?
When I try to use the public html route it works fine locally but once its built out I think Gatsby somehow is removing the script tags so it never shows up on the builds as far as the widget being on the site.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
React hooks in react library giving Invalid hook call error
(I don't want to publish every time I want to test) and I encountered the same issue. Invalid hook call. Hooks can only...
Read more >Invalid Hook Call Warning - React
There are three common reasons you might be seeing it: You might have mismatching versions of React and React DOM. You might be...
Read more >Test fails because "Invalid hook call." · Issue #147 - GitHub
Home page › renders without crashing Invalid hook call. Hooks can only be called inside of the body of a function component.
Read more >Invalid hook call - How to resolve multiple versions of React ...
Invalid hook call ? If you've seen this and are trying to solve it, here's a quick tip to make your life easier...
Read more >Fix Invalid Hook Call Warning in React Tests - Sinistra
In my opinion, hooks were the missing puzzle piece in the API developed by React. You get your first custom hook working, everything...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Haven’t forgotten about this just in Berlin this week so I’ll get to it shortly.
Closing this out for now, I went a different direction and I’m just doing React now based on a few things.