react-native-qrcode-svg
Advanced tools
Comparing version 1.0.3 to 1.0.4
20
index.js
@@ -8,7 +8,14 @@ // core | ||
/** | ||
* A simple component for displaying QR Code using svg | ||
*/ | ||
export default class QRCode extends Component { | ||
static propTypes = { | ||
/* what the qr code stands for */ | ||
value: PropTypes.string, | ||
/* the whole component size */ | ||
size: PropTypes.number, | ||
/* the color of the cell */ | ||
color: PropTypes.string, | ||
/* the color of the background */ | ||
backgroundColor: PropTypes.string, | ||
@@ -24,4 +31,5 @@ }; | ||
super(props); | ||
this._matrix = null; | ||
this._cellSize = null; | ||
this._matrix = null; | ||
this._path = null; | ||
this.setMatrix(props); | ||
@@ -33,4 +41,8 @@ } | ||
componentWillUpdate(nextProps) { | ||
this.setMatrix(nextProps); | ||
// if value has changed, re-setMatrix | ||
if (nextProps.value !== this.props.value) { | ||
this.setMatrix(nextProps); | ||
} | ||
} | ||
/* calculate the size of the cell and draw the path */ | ||
setMatrix(props) { | ||
@@ -41,3 +53,5 @@ const { value, size } = props; | ||
this._cellSize = size / (this._matrix.length + 2); | ||
this._path = this.transformMatrixIntoPath(); | ||
} | ||
/* project the matrix into path draw */ | ||
transformMatrixIntoPath() { | ||
@@ -84,3 +98,3 @@ const matrix = this._matrix; | ||
<Path | ||
d={this.transformMatrixIntoPath()} | ||
d={this._path} | ||
stroke={color} | ||
@@ -87,0 +101,0 @@ strokeWidth={this._cellSize} |
{ | ||
"name": "react-native-qrcode-svg", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A QR Code generator for React Native based on react-native-svg and javascript-qrcode.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# react-native-qrcode-svg | ||
A QR Code generator for React Native based on react-native-svg and javascript-qrcode. | ||
![screenshot](./screenshot.png) | ||
Please install react-native-svg first. | ||
@@ -4,0 +7,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23609
6
99
35