Skip to content

Commit

Permalink
Update Networking.md
Browse files Browse the repository at this point in the history
I ran into an `undefined is not a constructor` when I tried initiating a WebSocket connection. I imported the WebSocket module like so:`import { WebSocket } from 'react-native'`. 

When I changed it to `import { WebSocketModule } from 'react-native'` it worked. So I see two possible solutions:

1. renaming the `WebSocketModule` to `WebSocket`
2. updating the docs

This PR is for facebook#2.
  • Loading branch information
ohwhen authored Mar 16, 2017
1 parent d5dda1b commit 015ad3a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/Networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ request.send();
React Native also supports [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), a protocol which provides full-duplex communication channels over a single TCP connection.

```js
import { WebSocketModule } from 'react-native';
var ws = new WebSocket('ws://host.com/path');
ws.onopen = () => {
Expand Down

0 comments on commit 015ad3a

Please sign in to comment.