Skip to content

Commit 0acfd25

Browse files
committed
initial implementation, add prettier and eslint
1 parent 98a973f commit 0acfd25

11 files changed

+8405
-1
lines changed

.eslintrc.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
},
6+
extends: [
7+
'plugin:react/recommended',
8+
'airbnb-base',
9+
'plugin:prettier/recommended',
10+
],
11+
parserOptions: {
12+
ecmaFeatures: {
13+
jsx: true,
14+
},
15+
ecmaVersion: 12,
16+
sourceType: 'module',
17+
},
18+
plugins: ['react'],
19+
rules: {
20+
'prettier/prettier': 'error',
21+
'react/prop-types': 'off',
22+
},
23+
settings: {
24+
react: {
25+
version: 'detect',
26+
},
27+
},
28+
};

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock.json

.prettierrc.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: true,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
};

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# react-native-webrtc-web-shim
2+
3+
> Add WebRTC support for `react-native-web`, with minimal changes to your existing React Native app.
4+
5+
## Requirements
6+
7+
This library assumes you have an existing `react-native` application using `react-native-webrtc`.
8+
9+
## Installation
10+
11+
Install via `npm` or `yarn`
12+
13+
```bash
14+
npm install react-native-webrtc-web-shim
15+
```
16+
17+
## Setup
18+
19+
### Replace Imports
20+
21+
Replace the import statement of `react-native-webrtc` to import from `react-native-webrtc-web-shim` instead.
22+
23+
```javascript
24+
-import { RTCPeerConnection } from 'react-native-webrtc';
25+
+import { RTCPeerConnection } from 'react-native-webrtc-web-shim';
26+
27+
```
28+
29+
### Change WebRTC Code
30+
31+
#### RTCView
32+
33+
When displaying the `RTCView` component, pass it the `stream` object as a prop instead of `streamURL`.
34+
35+
```javascript
36+
<RTCView
37+
-streamURL={stream.toURL()}
38+
+stream={stream}
39+
/>
40+
```
41+
42+
#### Track Listener
43+
44+
Add an `ontrack` listener to your `RTCPeerConnection` object, similar to the `onaddstream` listener.
45+
46+
```javascript
47+
webRtcPeer.onaddstream = async ({ stream }) =>
48+
await addVideo(sessionId, stream);
49+
// add an ontrack listener for Safari support
50+
webRtcPeer.ontrack = async ({ track, streams }) => {
51+
if (track.kind === 'video') {
52+
await addVideo(sessionId, streams[0]);
53+
}
54+
};
55+
```

0 commit comments

Comments
 (0)