Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ module.exports = HelloWorld;
```
## Available Props

prop | type | default value
----------|----------------------|--------------
`value` | `string` | `http://facebook.github.io/react-native/`
`size` | `number` | `128`
`bgColor` | `string` (CSS color) | `"#000"`
`fgColor` | `string` (CSS color) | `"#FFF"`
prop | type | default value
--------------------|----------------------|--------------
`value` | `string` | `http://facebook.github.io/react-native/`
`size` | `number` | `128`
`bgColor` | `string` (CSS color) | `"#000"`
`fgColor` | `string` (CSS color) | `"#FFF"`
`errorCorrectLevel` | `number` (1, 0, 3, 2)| `"2"`


<img src='qrcode.png' height = '256' width = '256'/>

Expand Down
11 changes: 10 additions & 1 deletion lib/QRCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ var QRCode = createReactClass({
fgColor: PropTypes.string,
onLoad: PropTypes.func,
onLoadEnd: PropTypes.func,
// possible values for error correction level
// same as qr.js
// L ( 7% ) : 1,
// M ( 15% ) : 0,
// Q ( 25% ) : 3,
// H ( 30% ) : 2
errorCorrectLevel: PropTypes.number
},

getDefaultProps: function() {
Expand All @@ -65,6 +72,7 @@ var QRCode = createReactClass({
size: 128,
onLoad: () => {},
onLoadEnd: () => {},
errorCorrectLevel: 2 // high error correction ( same as qr.js default )
}
},

Expand All @@ -91,6 +99,7 @@ var QRCode = createReactClass({
render: function() {
var size = this.props.size;
var value = this.utf16to8(this.props.value);
var errorCorrectLevel = this.props.errorCorrectLevel;
return (
<View>
<Canvas
Expand All @@ -99,7 +108,7 @@ var QRCode = createReactClass({
value: this.props.value,
bgColor: this.props.bgColor,
fgColor: this.props.fgColor,
cells: qr(value).modules,
cells: qr(value, { errorCorrectLevel }).modules,
}}
render={renderCanvas}
onLoad={this.props.onLoad}
Expand Down