Skip to content

Not compatible with server rendering #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
chrisjpatty opened this issue Nov 13, 2017 · 3 comments
Open

Not compatible with server rendering #19

chrisjpatty opened this issue Nov 13, 2017 · 3 comments

Comments

@chrisjpatty
Copy link

chrisjpatty commented Nov 13, 2017

First of all, thanks for making this package, it's been really useful for our client-side React projects. When we attempt to server render our React code , however, using the renderToStaticMarkup() method available from ReactDOMserver, it renders empty SVG tags. While looking through the code, it appears that the SVG rendering requires that the target environment be an actual DOM. Is there any way to make this package compatible with a non-browser environment?

@Makhlab
Copy link

Makhlab commented Jul 25, 2018

Ran into the same issue. 💯

@kachkaev
Copy link

Hmm... JsBarcode seems to be isomorphic: lindell/JsBarcode#25

What's blocking server-side rendering then? 🤔

@capi1O
Copy link

capi1O commented Feb 6, 2019

Ran into this issue trying to convert to HTML string with canvg :

const htmlString = ReactDOMServer.renderToStaticMarkup(<Barcode value="http://www.google.com" />);
canvg(this.canvas, htmlString);
this.barcodeImageSrc = this.canvas.toDataURL('image/png');

from https://blog.usejournal.com/lets-make-a-resume-in-react-2c9c5540f51a

Need to do this because I output to a PDF using kendo PDFExport which does not support SVG.

Edit : After looking at the code there is actually an undocumented renderer prop which accepts svg, canvas and img which solves my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants