botfront / rasa-webchat

A feature-rich chat widget for Rasa and Botfront
https://botfront.io/rasa
Apache License 2.0
945 stars 495 forks source link

React integration #464

Closed Wtreck closed 1 year ago

Wtreck commented 1 year ago

I tried to integrate the following code, which is the latest one from the docs, into a react custom component, but I got the following error:

Error: ERROR Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem. Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
  4. You might have mismatching versions of React and the renderer (such as React DOM)
  5. You might be breaking the Rules of Hooks
  6. You might have more than one copy of React in the same app See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem. at resolveDispatcher (http://localhost:3000/static/js/bundle.js:84586:17) at useRef (http://localhost:3000/static/js/bundle.js:84620:24) at http://localhost:3000/static/js/bundle.js:61345:31 at renderWithHooks (http://localhost:3000/static/js/bundle.js:21236:22) at updateForwardRef (http://localhost:3000/static/js/bundle.js:23807:24) at beginWork (http://localhost:3000/static/js/bundle.js:25854:20) at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:10828:18) at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:10872:20) at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:10929:35) at beginWork$1 (http://localhost:3000/static/js/bundle.js:30803:11)

Code: import React, { Component } from 'react'; import Widget from 'rasa-webchat';

class CustomWidget extends Component { render() { return ( <Widget initPayload={"/get_started"} socketUrl={"http://localhost:5005"} socketPath={"/socket.io/"} customData={{"language": "en"}} // arbitrary custom data. Stay minimal as this will be added to the socket title={"Title"} /> ); } }

export default CustomWidget;

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.