@bsonntag/react-user-media
v0.1.0
Published
A react component that wraps getUserMedia.
Maintainers
Readme
@bsonntag/react-user-media
A react component that wraps
getUserMedia.
Installation
Using npm:
$ npm install --save @bsonntag/react-user-mediaUsing yarn:
$ yarn add @bsonntag/react-user-mediaThis module uses react's createContext API,
so make sure you have at least version 16.3.0 installed.
Example usage
import UserMedia from '@bsonntag/react-user-media';
import React from 'react';
const constraints = { video: true };
const App = () => (
<UserMedia constraints={constraints}>
{stream => (
<video
autoPlay
src={URL.createObjectURL(stream)}
/>
)}
</UserMedia>
);Props
children- A function that receives theMediaStreamand renders something.constraints- AMediaStreamConstraints.onError- A function that is called whengetUserMediathrows.onMediaStream- A function that receives theMediaStream.placeholder- An element that is rendered whilegetUserMediais being called.renderError- A function that receives the error thrown bygetUserMediaand renders something.
Contributing
Please feel free to submit any issues or pull requests.
License
MIT
