Skip to content

Commit

Permalink
Merge pull request #6 from joshgentry/master
Browse files Browse the repository at this point in the history
Fixes WebWorker usage to correct build issues
  • Loading branch information
Tigran Bayburtsyan authored Jul 10, 2019
2 parents 87367b0 + be9645b commit 5508c55
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { Component } from "react";
import PropTypes from 'prop-types';
import VideoStream from './video_stream';
import QRWorker from './qr_decode.worker';

const wrapperStyles = {
display: 'flex',
Expand All @@ -13,7 +12,7 @@ class ReactiveQR extends Component {
webWorker = null;

componentWillMount() {
this.webWorker = new QRWorker();
this.webWorker = new Worker('qr_decode.worker.js');
this.webWorker.addEventListener('message', this.onFrameDecoded);
}

Expand All @@ -36,13 +35,13 @@ class ReactiveQR extends Component {
}

onFrame = (frameData) => this.webWorker.postMessage(frameData);
drawVideoFrame = () => {}
drawVideoFrame = () => { }

onFrameDecoded = (event) => {
const code = event.data;
if (code) {
const { data } = code;
if ( this.props.onCode && data.length > 0 ) {
if (this.props.onCode && data.length > 0) {
this.props.onCode(code);
}
}
Expand All @@ -54,7 +53,7 @@ class ReactiveQR extends Component {

render() {
return (
<div className={this.props.className} style={{...wrapperStyles, ...this.props.style}}>
<div className={this.props.className} style={{ ...wrapperStyles, ...this.props.style }}>
<VideoStream
onFrame={this.onFrame}
onInit={this.onVideoStreamInit}
Expand All @@ -77,9 +76,9 @@ ReactiveQR.propTypes = {
};

ReactiveQR.defaultProps = {
onInit: () => {},
onInit: () => { },
shouldDecode: true,
onCode: () => {},
onCode: () => { },
style: {},
videoStyle: {},
rearCamera: true,
Expand Down

0 comments on commit 5508c55

Please sign in to comment.