Skip to content
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

Does not work with react #97

Open
martinlundin opened this issue Sep 20, 2019 · 2 comments
Open

Does not work with react #97

martinlundin opened this issue Sep 20, 2019 · 2 comments

Comments

@martinlundin
Copy link

martinlundin commented Sep 20, 2019

I get an error when including the rocket.chat/sdk in a react app.

Steps to reproduce:
yarn create react-app testchat
cd testchat
yarn add @rocket.chat/sdk

open App.js and add:
import { driver, methodCache, api } from '@rocket.chat/sdk'
Now when we run:
npm start
there is this error:

TypeError: Cannot read property 'map' of null
(anonymous function)
node_modules/websocket-driver/lib/websocket/http_parser.js:88
  85 |   31: 'LINK',
  86 |   32: 'UNLINK'
  87 | };
> 88 | var VERSION = (process.version || '').match(/[0-9]+/g).map(function (n) {
  89 |   return parseInt(n, 10);
  90 | });
  91 | 

What can I do to make this work together?
Thanks

@martinlundin
Copy link
Author

Same error when I try to import it to Vue/Nuxt.

To reproduce error:
yarn create nuxt-app nuxttestchat
open pages/index.vue and add:
import { driver, methodCache, api } from '@rocket.chat/sdk'
run:
yarn run dev
Same error as before with websocket http_parser.js

@andrewlorenz
Copy link

I had the same error too, and fixed it by updating your package.json entry for the sdk to this:
"@rocket.chat/sdk": "1.0.0-alpha.30"
This version is the one used by RC's own react-native client, and also worked for me when trialing with plain react.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants