zpao / qrcode.react

A <QRCode/> component for use with React.

Home Page:https://zpao.github.io/qrcode.react/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QRCodeSVG renders as Canvas instead of SVG

chasemcdo opened this issue · comments

In order to get QRCodeSVG to render as an SVG I have to pass in renderAs="svg". Otherwise I am seeing it render as a Canvas.

Can you share code reproducing the issue? I haven't seen that before.

Is it possible you're aliasing at import? For example…

import {QRCode as QRCodeSVG} from 'qrcode.react';

I simply have the following:
import QRCodeSVG from "qrcode.react";

With the following for displaying:

<QRCodeSVG
  value={link}
  renderAs="svg"
  width={130}
  height={130}
/> 

where when I had omitted the renderAs param it displayed as a canvas. I noticed since my current use case doesn’t seem to work with Canvas containers and when inspecting that appeared to be the issue which was resolved by adding the param.

Now noticing my lack of curly brackets which is likely leading to an unintentional aliasing of the default export

Ah yea, that would do it! In v4, I'm dropping the default export. It wasn't actually because of the potential confusion, just that it didn't add any value over the explicit svg/canvas components and hampered differentiation.

Glad you got it worked out!