Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Commit

Permalink
fix: remove size prop deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
no23reason committed Jun 20, 2017
1 parent 3541f1c commit 2052735
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/components/qr-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,21 @@ import PropTypes from 'prop-types';
const QRCodeImpl = require('qr.js/lib/QRCode');
const ErrorCorrectLevel = require('qr.js/lib/ErrorCorrectLevel');

let warningFired = false;

export function QRCode({
value = '',
size,
level = 'L',
bgColor = '#FFFFFF',
fgColor = '#000000',
...otherProps
} = {}) {
if (size && !warningFired) {
/* eslint-disable no-console */
console.warn('The \'size\' prop is deprecated and will be removed in the next major version. Please use the \'style\', \'className\' or \'width\' props to size the code.');
/* eslint-enable no-console */
warningFired = true;
}
// adapted from https://github.com/zpao/qrcode.react/blob/master/src/index.js
const qrcode = new QRCodeImpl(-1, ErrorCorrectLevel[level]);
qrcode.addData(value);
qrcode.make();

const cells = qrcode.modules;

return (<svg shapeRendering="crispEdges" viewBox={[0, 0, cells.length, cells.length].join(' ')} width={size} {...otherProps}>
return (<svg shapeRendering="crispEdges" viewBox={[0, 0, cells.length, cells.length].join(' ')} {...otherProps}>
{
cells.map((row, rowIndex) =>
row.map((cell, colIndex) => (
Expand Down

0 comments on commit 2052735

Please sign in to comment.