react-native-qrcode-svg
Version:
A QR Code generator for React Native based on react-native-svg and javascript-qrcode.
8 lines (6 loc) • 352 B
JavaScript
import QRCode from 'qrcode'
export default (value, errorCorrectionLevel) => {
const arr = Array.prototype.slice.call(QRCode.create(value, { errorCorrectionLevel }).modules.data, 0)
const sqrt = Math.sqrt(arr.length)
return arr.reduce((rows, key, index) => (index % sqrt === 0 ? rows.push([key]) : rows[rows.length - 1].push(key)) && rows, [])
}