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

Commit

Permalink
feat: add deprecation warning for size prop
Browse files Browse the repository at this point in the history
  • Loading branch information
no23reason committed Jun 20, 2017
1 parent bd4e4ab commit 804d25b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The props available are (shown with default values):
```js
{
value: '', // The value to encode in the code
size: 256, // Size of the code in pixels
size: 256, // Size of the code in pixels. This is obsolete and will be removed in the next major version!
level: 'L', // QR Error correction level
bgColor: '#FFFFFF', // Color of the bright squares
fgColor: '#000000', // Color of the dark squares
Expand Down
8 changes: 8 additions & 0 deletions src/components/qr-svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ 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,
Expand All @@ -12,6 +14,12 @@ export function QRCode({
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);
Expand Down

0 comments on commit 804d25b

Please sign in to comment.