Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
fix: QR code of normal swaps
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Jan 7, 2020
1 parent ddd5e42 commit 82355c7
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/components/qrcode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import Qrious from 'qrious';
import PropTypes from 'prop-types';

class QrCode extends React.Component {
render() {
const { size, link } = this.props;

if (link) {
this.id = `qr-${link.substring(0, 4)}`;
id = '';

drawQrCode = () => {
if (this.id !== '') {
const { size, link } = this.props;
const element = document.getElementById(this.id);

this.qr = new Qrious({
element,
});
Expand All @@ -24,8 +24,26 @@ class QrCode extends React.Component {
foregroundAlpha: 1,
});
}
};

componentDidUpdate() {
this.drawQrCode();
}

return <canvas id={this.id} />;
componentDidMount() {
this.drawQrCode();
}

render() {
const { link } = this.props;

if (link) {
this.id = `qr-${link.substring(0, 4)}`;

return <canvas id={this.id} />;
} else {
return <div />;
}
}
}

Expand Down

0 comments on commit 82355c7

Please sign in to comment.