Giter Site home page Giter Site logo

react-native-qrcode-svg's Introduction

Looking for maintainers

I'm not working on any React Native projects anymore. Feel free to take over this project if you feel good about it!

NPM circleci

react-native-qrcode-svg

A QR Code generator for React Native based on react-native-svg and javascript-qrcode.

Discussion: https://discord.gg/RvFM97v

Features

  • Easily render QR code images
  • Optionally embed a logotype
Android iOS

Installation

Install dependency packages

yarn add react-native-svg react-native-qrcode-svg

Or

npm i -S react-native-svg react-native-qrcode-svg

If you are using React Native 0.60.+ go to the folder your-project/ios and run pod install, and you're done.

If not, use one of the following method to link.

Link with react-native link

If you are using React Native <= 0.59.X, link the native project:

react-native link react-native-svg

Examples

import QRCode from 'react-native-qrcode-svg';

// Simple usage, defaults for all but the value
render() {
  return (
    <QRCode
      value="http://awesome.link.qr"
    />
  );
};
// 30px logo from base64 string with transparent background
render() {
  let base64Logo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAA..';
  return (
    <QRCode
      value="Just some string value"
      logo={{uri: base64Logo}}
      logoSize={30}
      logoBackgroundColor='transparent'
    />
  );
};
// 20% (default) sized logo from local file string with white logo backdrop
render() {
  let logoFromFile = require('../assets/logo.png');
  return (
    <QRCode
      value="Just some string value"
      logo={logoFromFile}
    />
  );
};
// get base64 string encode of the qrcode (currently logo is not included)
getDataURL() {
  this.svg.toDataURL(this.callback);
}

callback(dataURL) {
  console.log(dataURL);
}

render() {
  return (
    <QRCode
      value="Just some string value"
      getRef={(c) => (this.svg = c)}
    />
  );
}

Props

Name Default Description
size 100 Size of rendered image in pixels
value 'this is a QR code' String Value of the QR code. Can also accept an array of segments as defined in Manual mode. Ex. [{ data: 'ABCDEFG', mode: 'alphanumeric' }, { data: '0123456', mode: 'numeric' }, { data: [253,254,255], mode: 'byte' }]
color 'black' Color of the QR code
backgroundColor 'white' Color of the background
enableLinearGradient false enables or disables linear gradient
linearGradient ['rgb(255,0,0)','rgb(0,255,255)'] array of 2 rgb colors used to create the linear gradient
gradientDirection [170,0,0,0] the direction of the linear gradient
logo null Image source object. Ex. {uri: 'base64string'} or {require('pathToImage')}
logoSize 20% of size Size of the imprinted logo. Bigger logo = less error correction in QR code
logoBackgroundColor backgroundColor The logo gets a filled quadratic background with this color. Use 'transparent' if your logo already has its own backdrop.
logoMargin 2 logo's distance to its wrapper
logoBorderRadius 0 the border-radius of logo image (Android is not supported)
quietZone 0 quiet zone around the qr in pixels (useful when saving image to gallery)
getRef null Get SVG ref for further usage
ecl 'M' Error correction level
onError(error) undefined Callback fired when exception happened during the code generating process

Saving generated code to gallery

Note: Experimental only ( not tested on iOS) , uses getRef() and needs RNFS module

npm install --save react-native-fs

Example for Android:

import { CameraRoll , ToastAndroid } from "react-native"
import RNFS from "react-native-fs"
...

  saveQrToDisk() {
   	this.svg.toDataURL((data) => {
   		RNFS.writeFile(RNFS.CachesDirectoryPath+"/some-name.png", data, 'base64')
   		  .then((success) => {
   			  return CameraRoll.saveToCameraRoll(RNFS.CachesDirectoryPath+"/some-name.png", 'photo')
   		  })
   		  .then(() => {
   			  this.setState({ busy: false, imageSaved: true  })
   			  ToastAndroid.show('Saved to gallery !!', ToastAndroid.SHORT)
   		  })
   	})
  }

Dependencies

PeerDependencies

Dependencies


If you like this project, please consider buy me a coffee :)

https://www.buymeacoffee.com/LquC7mid5

react-native-qrcode-svg's People

Contributors

awesomejerry avatar cvvspb avatar douglasjunior avatar dyy2016 avatar emad-salah avatar gbhasha avatar haikov avatar henrikgs avatar honter36 avatar johnydnu avatar kamyar avatar kiranjd avatar liuqiang1357 avatar msageryd avatar nfrolov avatar rghorbani avatar roconda avatar saidybarry avatar torkelrogstad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-qrcode-svg's Issues

Couldn't find preset "ES2015" relative to directory

I've created a new project to test the module but I get the following error when trying to import the project. I think it's something related with Babel.

screen shot 2017-03-14 at 4 13 14 pm

Here's my package.json

{
	"name": "TestGenerateQR",
	"version": "0.0.1",
	"private": true,
	"scripts": {
		"start": "node node_modules/react-native/local-cli/cli.js start",
		"test": "jest"
	},
	"dependencies": {
		"react": "~15.4.1",
		"react-native": "0.42.0",
		"react-native-qrcode-svg": "^4.0.0",
		"react-native-svg": "^5.1.5"
	},
	"devDependencies": {
		"babel-jest": "19.0.0",
		"babel-preset-react-native": "1.9.1",
		"jest": "19.0.2",
		"react-test-renderer": "~15.4.1"
	},
	"jest": {
		"preset": "react-native"
	}
}

Babel trouble

I'd really want to try out this module. But I get all kinds of trouble. I see that you have committed a new .babelrc a couple of days ago. Might this module be in kind of an unstable shape for the moment? Or is the problem with my setup?

Node 6.9
RN 0.36.1 (also tried with 0.34)

Problems I get:
"Couldn't find preset ES2015..."

  • Shouldn't npm modules install whatever dependencies they need? Including Babel stuff?

"Unmet peer dependency react-native-svg@^4.3.1"
"peer dep missing: react-native-svg@^4.3.1, required by [email protected]"

  • But I have 4.3.1 installed

"Transform error.. Invalid option"
image

Could not find method implementation() for arguments

FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/kapil/Desktop/ReactNativeApplication/demoApps/qrcodecreator/node_modules/react-native-svg/android/build.gradle' line: 52

  • What went wrong:
    A problem occurred evaluating project ':react-native-svg'.

Could not find method implementation() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.de
pendencies.DefaultDependencyHandler.

cannot read a qrcode when write a option value (backgroundColor & color)

When I put the option below, a QR was created but could not be read.

<QRCode
  value={item.value}
  size={180}
  backgroundColor="#0052BE"
  color="#fff"
/>

When I debugged it, it seems that if the backgroundColor and color values ​​are entered into the rgb code, they are generated normally but cannot be read.

Can it convert this format?

I'm using https://github.com/dtinth/promptpay-qr to generate the qr code value that ends up as shown below, it doesn't seem to display properly using this library, just shows as random dotted lines, is this kind of data supported please?
Value: data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2037%2037%22%3E%3Cpath%20fill%3D%22%23ffffff%22%20d%3D%22M0%200h37v37H0z%22%2F%3E%3Cpath%20stroke%3D%22%23000000%22%20d%3D%22M4%204.5h7m2%200h3m1%200h3m2%200h1m3%200h7M4%205.5h1m5%200h1m4%200h3m1%200h5m2%200h1m5%200h1M4%206.5h1m1%200h3m1%200h1m2%200h3m1%200h1m8%200h1m1%200h3m1%200h1M4%207.5h1m1%200h3m1%200h1m1%200h1m1%200h2m1%200h2m2%200h1m2%200h1m1%200h1m1%200h3m1%200h1M4%208.5h1m1%200h3m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h3m1%200h1M4%209.5h1m5%200h1m2%200h2m2%200h1m5%200h1m2%200h1m5%200h1M4%2010.5h7m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h1m1%200h7M13%2011.5h1m2%200h1m1%200h1m2%200h3M4%2012.5h2m3%200h3m1%200h2m1%200h2m2%200h1m1%200h1m1%200h1m3%200h2M4%2013.5h1m6%200h2m1%200h1m3%200h2m1%200h2m2%200h2m5%200h1M5%2014.5h4m1%200h2m1%200h1m1%200h2m2%200h3m1%200h1m1%200h1m2%200h1m1%200h2M5%2015.5h2m1%200h1m2%200h1m2%200h2m6%200h2m4%200h1M4%2016.5h1m1%200h2m2%200h5m2%200h2m1%200h1m1%200h5m1%200h1m3%200h1M4%2017.5h4m1%200h1m1%200h1m1%200h2m1%200h1m1%200h1m1%200h1m7%200h2m2%200h1M7%2018.5h2m1%200h5m2%200h1m1%200h1m1%200h1m2%200h2m5%200h1M4%2019.5h4m1%200h1m1%200h1m1%200h1m2%200h3m1%200h1m2%200h1m2%200h1m2%200h1m1%200h1M5%2020.5h1m3%200h5m2%200h2m2%200h1m2%200h1m1%200h1m2%200h2m1%200h1M4%2021.5h1m1%200h3m2%200h4m3%200h1m1%200h2m1%200h2m2%200h2M4%2022.5h2m2%200h4m1%200h2m1%200h3m1%200h2m1%200h7m1%200h2M4%2023.5h1m1%200h1m4%200h2m2%200h1m5%200h2m5%200h2M4%2024.5h1m2%200h1m1%200h5m1%200h1m3%200h1m2%200h8m1%200h1M12%2025.5h3m1%200h3m2%200h2m1%200h1m3%200h1m3%200h1M4%2026.5h7m1%200h1m4%200h3m2%200h3m1%200h1m1%200h1m1%200h2M4%2027.5h1m5%200h1m1%200h2m2%200h2m3%200h2m1%200h1m3%200h4M4%2028.5h1m1%200h3m1%200h1m3%200h4m2%200h9m3%200h1M4%2029.5h1m1%200h3m1%200h1m2%200h2m4%200h1m2%200h1m5%200h1M4%2030.5h1m1%200h3m1%200h1m2%200h1m1%200h2m5%200h1m2%200h2m1%200h1m2%200h1M4%2031.5h1m5%200h1m1%200h1m2%200h1m6%200h3m2%200h2m2%200h2M4%2032.5h7m1%200h2m1%200h1m3%200h2m2%200h1m1%200h2m1%200h1m2%200h1%22%2F%3E%3C%2Fsvg%3E

Can't embed in SVG

<Svg height="756" width="375" >
                            <Rect
                                x="0"
                                y="0"
                                width="100%"
                                height="100%"
                                fill="white"
                            />
                        <Image x="0" width="375" height="605" href={ShareImage}/>
                        <Text
                                x="27"
                                y="661"
                                textAnchor="middle"
                                fontWeight="bold"
                                fontSize="16"
                                fill="blue"
                            >Welcome</Text>
                        <QRCode size={100}/>
                    </Svg>

Can not work.

Proposal of channel discussion

Hi, I took the liberty of creating a public chat in the discord facing React-Native. With the intention of uniting the React-native community and improving communication.

I'm creating a channel for public discussions about your project. To avoid flooding "chat" on your github. If you can support the initiative, great! Just share the link below xD

I'm adding RN only projects to this public chat service. And I commit myself to manage chat rooms.

here's the link
https://discord.gg/RvFM97v

Cheers.

Set size of generated image

How can I set the size of generated image in px Because right now it depends on the element size, and it depends on screen size of device.

lib support

I need user the react-native version(react=15.1.0, react-native=0.28.0), then I try to run your lib, �nonsupport!Xcode show the error('RCTFont.h' file not found). How would we get over that problem?

Logo don't show in Android

I'm using this lib in my application, and is simple and fast. But in Android the image logo don't show in QrCode.

<QRCode value="my value" size={200} logo={require('img/qr_icon.png')} logoSize={80} logoBackgroundColor="transparent" />

I imported the lib:
import QRCode from 'react-native-qrcode-svg';

On iPhone is allright, fantastic, but in the Android the logo don't show....
Why?

Value other than string

Hi there,
I'm trying to pass an API POST endpoint with the body as an async function into the value
value={this.postData()}
I keep getting an error back. Is there a way to do what I'm trying to do? I'm ultimately using the QR code to send that API request when the code is scanned.

Not working on Android Pie

Hi

I've been trying to use the library on Android pie but it doesn't seem to work. I can't change the color as well as background color of the QR Code and nothing is being generated as well.

Any suggestions?

Width and height must be > 0 when save barcode.

Hi, I have a problem when saving the QR code. This problem like that:
width and height must be > 0
createBitmap
Bitmap.java:830
createBitmap
Bitmap.java:776
toDataUrl
SvgViewShadowNode.java:202
toDataUrl
SvgViewModule.java:34
invoke
Method.java
invoke
Method.java
JavaMethodWrapper.java:473
invoke
JavaMethodWrapper.java:374
invoke
JavaModuleWrapper.java:162
run
NativeRunnable.java

Warning: componentWillUpdate is deprecated and will be removed in the next major version.

Hi. I'm just reporting this warning. But the component remains functional in my environment.

"Warning: componentWillUpdate is deprecated and will be removed in the next major version. Use componentDidUpdate instead."
"Please update the following components: QRCode"

react-native -v

react-native-cli: 2.0.1
react-native: 0.60.3

Environment

Ubuntu 19.04
Open JDK 1.8.0_212, build vendor: Azul Systems
Device (emulated): Pixel 3 XL with Android Pie x86 image

Rounded Images

I am loading user avatars dynamically over the network and placing them in the middle of the QR code. They are rendered with square corners which looks a little off for my app given that every other avatar in the app is circular (borderRadius: 50%).

Is it possible to specify style attributes to the image that gets rendered in the center so I can make it round?

Result of value from generated QRCode is different from the real value

I use these codes to generate QRCode for my project.

<QRCode value='Just some string value' size={200} logo={Images.logoMtfBlue} logoSize={100}

there is a problem when I add "logo" to my QRCode. The result when I scan the QRCode should be text "Just some sting value" BUT it is not. The result is random number. but when I just use the value without adding any logo or image, everything is okay. Is there any solution?

toDataURL

Hi, how am i suppose to use toDataURL to show the QrCode to an Image component? The code below does not shows anything

state = {
    logoBase64: "test"
  };

  handlePress = () => {
    this.qrcode.toDataURL(this.callback);
  };

  callback = dataURL => {
    this.setState({ logoBase64: dataURL });
  };

  render() {
    return (
      <ScrollView contentContainerStyle={styles.container}>
        <View style={styles.section}>
          <QRCode
            value="hello world"
            logo={require(PATH_TO_LOGO)}
            logoBackgroundColor="blue"
            getRef={c => (this.qrcode = c)}
          />
          <Button title={"getDataURL"} onPress={this.handlePress} />
        </View>

        <Image
          source={{ uri: this.state.logoBase64 }}
          style={{ width: 100, height: 100 }}
        />
      </ScrollView>
    );
  }
}

RNSVGSvgViewManager.toDataURL

getDataURL() {
this.svg.toDataURL(this.callback);
}
callback(dataURL) {
console.log(dataURL);
}
render() {
return (
<QRCode
value="Just some string value"
getRef={(c) => (this.svg = c)}
/>
);
}

Implemented same way.....

Getting error "Undefined is not an object ('evaluating RNSVGSvgViewManager.toDataURL')"

[email protected] requires a peer of [email protected] but none was installed.

I tried as readme show.
Please install react-native-svg first.

npm install react-native-svg --save
react-native link react-native-svg
npm install react-native-qrcode-svg --save

but the following errors are displayed.

npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of [email protected] but none was installed.
iMac27-no-iMac:AwesomeProjectSVG itagaki$ react-native -v
react-native-cli: 1.0.0
react-native: 0.33.1
iMac27-no-iMac:AwesomeProjectSVG itagaki$ npm install react-native-svg --save
[email protected] /Users/itagaki/testxx/AwesomeProjectSVG
├── UNMET PEER DEPENDENCY [email protected]
├── UNMET PEER DEPENDENCY [email protected]
└── UNMET PEER DEPENDENCY [email protected]

npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm ERR! code 1
iMac27-no-iMac:AwesomeProjectSVG itagaki$ npm install --save [email protected]
[email protected] /Users/itagaki/testxx/AwesomeProjectSVG
├── UNMET PEER DEPENDENCY [email protected]
├── UNMET PEER DEPENDENCY [email protected]
└── UNMET PEER DEPENDENCY [email protected]

npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of react@^15.3.2 but none was installed.
npm ERR! code 1
iMac27-no-iMac:AwesomeProjectSVG itagaki$ npm install react-native-svg --save
[email protected] /Users/itagaki/testxx/AwesomeProjectSVG
├── UNMET PEER DEPENDENCY [email protected]
├── UNMET PEER DEPENDENCY [email protected]
└── UNMET PEER DEPENDENCY [email protected]

npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of react@^15.3.2 but none was installed.
npm ERR! code 1
iMac27-no-iMac:AwesomeProjectSVG itagaki$ react-native link react-native-svg
rnpm-install info Android module react-native-svg is already linked
rnpm-install info iOS module react-native-svg is already linked
iMac27-no-iMac:AwesomeProjectSVG itagaki$ npm install react-native-qrcode-svg --save
[email protected] /Users/itagaki/testxx/AwesomeProjectSVG
├── UNMET PEER DEPENDENCY [email protected]
├── UNMET PEER DEPENDENCY [email protected]
├─┬ [email protected]
│ └── [email protected] (git+https://github.com/awesomejerry/javascript-qrcode.git#0a51f31226b92ee276d51e10bd98c4989d3549a9)
└── UNMET PEER DEPENDENCY [email protected]

npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN [email protected] requires a peer of react@^15.3.2 but none was installed.
iMac27-no-iMac:AwesomeProjectSVG itagaki$

could someone help me on this?

Logo is not showing

Code
<QRCode value={this.props.renterref} size={200} logo={require('../assets/images/tick.png')} logoBackgroundColor='transparent' />

react-native-qrcode-svg version: 5.1.0
react-native-svg version:5.5.1

The logo not display correct

code:

<QRCode
                        value="http://awesome.link.qr"
                        size={220}
                        color={accent}
                        backgroundColor={surface}
                        logo={require('../../assets/logo/my.png')}
                        logoBackgroundColor="transparent"
                        logoSize={50}
                    />

IMG_85D936BE81A3-1

Unable to hide component

QRCode is unable to hide using style

<QRCode style={{visibility:"hidden"}} value={this.state.text} size={200} />

lack lib

I try to link lib, But Xcod without RCTFont lib,and Xcod cann't run.

Crash on Android Pie

App is crashing when running on Android Pie on emulator.

Appears to be related to clipPath and clipRect being deprecated since Android 26:
https://developer.android.com/reference/android/graphics/Canvas#clipPath(android.graphics.Path,%20android.graphics.Region.Op)

Could also be related to this issue with react-native-svg:
software-mansion/react-native-svg#766

Getting the following error when rendering a QR code:

Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed
checkValidClipOp
Canvas.java:779
clipPath
Canvas.java:1007
clip
VirtualNode.java:263
draw
RenderableShadowNode.java:213
run
GroupShadowNode.java:82
traverseChildren
VirtualNode.java:349
drawGroup
GroupShadowNode.java:73
draw
GroupShadowNode.java:64
run
SvgViewShadowNode.java:193
traverseChildren
SvgViewShadowNode.java:282
drawChildren
SvgViewShadowNode.java:188
drawOutput
SvgViewShadowNode.java:140
onCollectExtraUpdates
SvgViewShadowNode.java:122
dispatchUpdates
ReactShadowNodeImpl.java:325
applyUpdatesRecursive
UIImplementation.java:968
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
applyUpdatesRecursive
UIImplementation.java:959
updateViewHierarchy
UIImplementation.java:700
dispatchViewUpdates
UIImplementation.java:654
onBatchComplete
UIManagerModule.java:663
onBatchComplete
NativeModuleRegistry.java:136
onBatchComplete
CatalystInstanceImpl.java:145
run
NativeRunnable.java
handleCallback
Handler.java:873
dispatchMessage
Handler.java:99
dispatchMessage
MessageQueueThreadHandler.java:31
loop
Looper.java:193
run
MessageQueueThreadImpl.java:194
run
Thread.java:764

Please update dependencies

Hi, and thanks for this package!

Could you please update and publish a new version updating react-native-svg dependency to latest version 6.5.2? I can confirm this package works fine with it.

This would prevent the following npm warning:

npm WARN [email protected] requires a peer of react-native-svg@^5.4.1 but none is installed. You must install peer dependencies yourself.

Logo Size

Hi, i was experimenting with the size of the logo and only 28% of the QR code size can be put in the logo size for it to be scan-nable...... could it be possible to increase the size of the logo, let just say up to 50% because i cant no longer scan the qr code if the logo size is above 29% of the actual qr code size

qrcode-svg version 5.0.5 doesn't work with react version 16.2

Tried the following combinations and couldn't get to work.

Scenario 1:
react-native-qrcode-svg: version 5.0.5
react-native-svg: version 5.4.1
react: version 16.0.0
==> Error message: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of Rect.

Scenario 2:
react-native-qrcode-svg: version 5.0.5
react-native-svg: version 6.0.1-rc.1
react: version 16.0.0
=> Error message: No component found for view with name "RNSVGRect"

Do I have to bump down the version of react to 16.0.0-alpha.12 to make it work?

Ability to handle generating errors

Hello,

I'd like to discuss the possibility of adding some kind of an error callback to the library.

I've started seeing the following error in crashlytics from users: Error: Error: The amount of data is too big to be stored in a QR Code. I've seen the #40 issue and probably setting ecl="L" would work, but I think we need some more systematic solution because Node's QRCode library throws a lot of errors https://github.com/soldair/node-qrcode/blob/master/lib/core/qrcode.js which could cause crashes in the app.

I think it would be enough to wrap this line:

const arr = Array.prototype.slice.call(QRCode.create(value, { errorCorrectionLevel }).modules.data, 0)

with try...catch and call an error callback.

What do you think about it?

svgRef.toDataURL() works on iOS but crash on Android + EXPO

Hi,

I'm using Expo, and according to documentation, react-native-svg is already linked.

I'm trying to use getRef={c => (this.qrcode = c)} to send the SVG as png,

but when

this.qrcode.toDataURL(base64 => {
       this._callback(base64);
     });

It crashes only on Android with the error:

TypeError: undefined is not an object (evaluating 'RNSVGSvgViewManager.toDataURL')

On iOS, it works perfectly!

Some idea?

"react-native-qrcode-svg": "^5.1.1",
"react-native-svg": "^6.5.2",

Any plans for "node-qrcode-svg"

I need to generate QR codes on my server (node.js). It could be accomplished by using about 90% of the code in react-native-qrcode-svg. I was wondering if you already have such a project laying around or of I should fork and make one on my own.

logo is not working

I have 1 QR code, i want to display the logo in that QR, I passed it a base64 uri but it does not work

TypeScript typings

There's currently no TypeScript typings for this package.

Would PR with typings be welcome?

Dependencies Need Upgrading

react-native-svg 6.5.2 is broken on android 9.0
Please upgrade this projects dependency to 9.5.1. I'm having no problems running at that version.

Logotype imprinting

Thanks again for a superb module.

I have implemented logotype imprinting in a fork, and I have some design questions before making a PR.

svg/bitmap
I have only implemented svg based logos. Would it be of interest if I also implement bitmap logos?

Bounding box
I need the bounding box for the svg path in order to fit it well. the simplest solution is to get the svg width and height explicitly via props. This is the solution I have implemented for now. More work for the user, less work for me =)

Another solution is to either fork or depend on this: https://github.com/icons8/svg-path-bounding-box

Yet another solution might be to wait for getBBox() to be implemented in react-native-svg. See:
software-mansion/react-native-svg#89

Many props
As of now I need quite some props from the user. Is this ok, or does it seem bloated?

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,
  /* a svg-string logo to imprint on the QR code,*/
  logo: PropTypes.string,
  /* logo width in pixels */
  logoWidth: PropTypes.number,
  /* logo height in pixels */
  logoHeight: PropTypes.number,
  /* should a background rectangle be painted under the logo? */
  paintLogoBackground: PropTypes.bool
  /* scale factor for your svg logo. Play with this to ensure your QR is scannable */
  logoScale: PropTypes.number
};

Example
Here is a QR code with an imprinted svg paw. The svg is exported from PhotoShop.
image

Here is the code for the above example:

<QRCode
  size={150}
  value= { 'test' }
  color='#6897bb'
  logoWidth={ 20 }
  logoHeight={ 20 }
  logo='M15.926,4.939 C15.316,7.067 13.742,8.484 12.412,8.105 C11.082,7.725 10.498,5.692 11.109,3.564 C11.720,1.437 13.293,0.019 14.623,0.399 C15.953,0.779 16.537,2.812 15.926,4.939 ZM6.539,0.013 C5.173,0.231 4.349,2.179 4.699,4.364 C5.049,6.550 6.440,8.146 7.806,7.928 C9.173,7.710 9.997,5.762 9.647,3.577 C9.297,1.391 7.906,-0.205 6.539,0.013 ZM1.324,6.033 C0.054,6.537 -0.376,8.446 0.362,10.297 C1.101,12.148 2.729,13.239 3.999,12.735 C5.268,12.231 5.699,10.322 4.960,8.471 C4.221,6.621 2.593,5.529 1.324,6.033 ZM18.746,7.404 C17.490,6.868 15.835,7.918 15.049,9.750 C14.264,11.582 14.646,13.501 15.903,14.036 C17.159,14.572 18.814,13.522 19.600,11.690 C20.385,9.859 20.002,7.939 18.746,7.404 ZM15.773,18.876 C17.324,17.233 13.095,10.439 9.993,10.298 C6.751,10.151 1.815,17.470 3.507,19.157 C5.199,20.845 8.301,19.439 9.993,19.157 C11.685,18.876 13.381,21.411 15.773,18.876 Z'}
  logoScale={ 1.55 }
  paintLogoBackground={ true}
  backgroundColor= 'white'  />

i have problem to use react-native-qrcode-svg + expo

Hello
My project create with create-react-native-app, i have problem to use react-native-qrcode-svg + expo
when I type terminal npm start or npm start --reset-cache
have this message in chrome browser -> Unable to resolve "react-native-svg" from "node_modules/react-native-qrcode-svg/src/index.js"
I google this problem and I found react-native-svg are Expo built-in not need to npm install react-native-svg
but my project still can not to run both install or not install react-native-svg
Have any idea or suggestion?
Sorry, my poor english

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.