olofd / react-native-signalr

Use SignalR with React Native
150 stars 61 forks source link

undefined is not an object: window.document.location.protocol #16

Closed ezyone123 closed 7 years ago

ezyone123 commented 7 years ago

I am getting an error that I believe is coming from the example project leaking into the include. It is coming from jquery.signalR.js.

My import looks like this: import signalr from 'react-native-signalr'; and I installed the library using npm install react-native-signalr --save

Any thoughts?

img_0767

olofd commented 7 years ago

iOS? Hmm.. Version 1.0?

ezyone123 commented 7 years ago

"react-native-signalr": "^1.0.0"

That is from my package.json.

olofd commented 7 years ago

react-native version ?

ezyone123 commented 7 years ago

0.40.0

ezyone123 commented 7 years ago

Is there any way the jquery library in the server example would be included with the native package ?

olofd commented 7 years ago

hmm.. testing a fresh project here right now... I'll report back soon.

ezyone123 commented 7 years ago

THANKS SO MUCH!

olofd commented 7 years ago

@ezyone123 hmm.. no problems here on a fresh project, connected and worked fine. Same import as yours. RN 0.40 and rn-signalr 1.0. The package.json:

{
  "name": "yyy",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "~15.4.0-rc.4",
    "react-native": "0.40.0",
    "react-native-signalr": "^1.0.0"
  },
  "devDependencies": {
    "babel-jest": "18.0.0",
    "babel-preset-react-native": "1.9.1",
    "jest": "18.1.0",
    "react-test-renderer": "~15.4.0-rc.4"
  },
  "jest": {
    "preset": "react-native"
  }
}

It might be that signalr-library conflicts with some other dependency you have. Could you post your package.json, or only the dependencies you have?

that window.location thing is a global hack that needs to be there for signalr-client to function. Nothing that awful, but it might conflict. Another question as well, are you running with any custom debugger?

ezyone123 commented 7 years ago
{
  "name": "TeamDynamix",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "flow": "node_modules/.bin/flow"
  },
  "dependencies": {
    "react": "15.4.2",
    "react-native": "0.40.0",
    "react-native-camera": "^1.0.0-alpha1",
    "react-native-code-push": "^1.16.1-beta",
    "react-native-cookies": "^2.0.0",
    "react-native-drawer": "^2.3.0",
    "react-native-fabric": "^0.4.0",
    "react-native-keychain": "^1.0.0",
    "react-native-maps": "^0.13.0",
    "react-native-onesignal": "^2.0.0",
    "react-native-orientation": "git+https://github.com/yamill/react-native-orientation.git",
    "react-native-router-flux": "^3.37.0",
    "react-native-signalr": "^1.0.0",
    "react-native-simple-store": "^1.1.0",
    "react-native-vector-icons": "^4.0.0",
    "react-redux": "^5.0.2",
    "redux": "^3.6.0",
    "redux-thunk": "^2.1.0"
  },
  "devDependencies": {
    "babel-jest": "18.0.0",
    "babel-preset-react-native": "1.9.1",
    "jest": "18.1.0",
    "react-test-renderer": "15.4.2",
    "flow-bin": "^0.37.4"
  },
  "jest": {
    "preset": "react-native"
  }
}
ezyone123 commented 7 years ago

I am using a error reporting service, its the fabric dependency.

olofd commented 7 years ago

Yes. I know fabric. I'll try installning all your dep and importing them before signalr and see if I can reproduce. You can try removing the others on at a time maybe. and see if you can get it running. You should also try a fresh project like i did with react-native init to see that it's not an issue with your env.

ezyone123 commented 7 years ago

importing your library into the root of my app does not result in any errors.

ezyone123 commented 7 years ago

and it only happens when I call connection.start

ezyone123 commented 7 years ago

I went though all my dependencies and none (other than yours) have a jquery dependency

olofd commented 7 years ago

Weird. The only way I can help you further is by testing you acutul source-code. If it's not that private of a project you can zip it and mail it to me at olof.dahlbom@me.com and I'll take a look.

ezyone123 commented 7 years ago

Turns out it was the URL I was passing in for the server. Is there a check to make sure the URL is a proper URL?

olofd commented 7 years ago

@ezyone123 Ah! Then there must be something here : https://github.com/olofd/react-native-signalr/blob/master/src/bridge.js#L28 Could you set a breakpoint there and see what goes wrong?

olofd commented 7 years ago

@ezyone123 Did you solve this? Please close the issue if you found a solution.

olofd commented 7 years ago

Closing

ezyone123 commented 7 years ago

I am sorry for not updating. The issue was the url passed in was what was causing the issue. Hard linking the url worked and I will later be testing getting the url set in a var. Ill update with findings. Thanks for closing.