question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid Hook Call - React Testing

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
btotharyecommented, Jan 7, 2020

Haven’t forgotten about this just in Berlin this week so I’ll get to it shortly.

0reactions
btotharyecommented, Feb 18, 2020

Closing this out for now, I went a different direction and I’m just doing React now based on a few things.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found