45 lines
944 B
JavaScript
Executable file
45 lines
944 B
JavaScript
Executable file
/* eslint-disable new-cap */
|
|
import React, {PropTypes} from 'react';
|
|
import qrcodejs, {CorrectLevel} from 'qrcodejs';
|
|
|
|
const QR_REF = 'QR_REF';
|
|
|
|
const QRCode = React.createClass({
|
|
propTypes: {
|
|
text: PropTypes.string.isRequired,
|
|
width: PropTypes.number,
|
|
height: PropTypes.number,
|
|
colorLight: PropTypes.string,
|
|
colorDark: PropTypes.string,
|
|
correctLevel: PropTypes.oneOf([CorrectLevel.L, CorrectLevel.M, CorrectLevel.Q, CorrectLevel.H]),
|
|
},
|
|
|
|
getDefaultProps() {
|
|
return {
|
|
width: 128,
|
|
height: 128,
|
|
colorLight: '#ffffff',
|
|
colorDark: '#000000',
|
|
correctLevel: CorrectLevel.M,
|
|
};
|
|
},
|
|
|
|
componentDidMount() {
|
|
new qrcodejs(this.refs[QR_REF], this.props);
|
|
},
|
|
|
|
componentDidUpdate() {
|
|
new qrcodejs(this.refs[QR_REF], this.props);
|
|
},
|
|
|
|
render() {
|
|
return <div ref={QR_REF} />;
|
|
},
|
|
});
|
|
|
|
export default QRCode;
|
|
|
|
|
|
|
|
// WEBPACK FOOTER //
|
|
// ./discord_app/components/QRCode.js
|