RapiPdf icon indicating copy to clipboard operation
RapiPdf copied to clipboard

Usage in React

Open rowbotman opened this issue 5 years ago • 2 comments

Hi! I am trying to use rapipdf in my react app, but I have a problem with it. So, I installed this package using: npm i rapipdf and then I import it in my app like it is presented in RapiDoc examples :

import 'rapipdf';
...
class MyComponent extends React.Component<MyProps, MyState> {
...
  render() {
     return (<rapi-pdf
                       spec-url={'/apis/api.yml'}
                       button-bg="#b44646"
             >
             </rapi-pdf>);
}

Unfortunately, within the compilation, I have an error:

ERROR in ./node_modules/rapipdf/src/rapipdf.js
Module not found: Error: Can't resolve '@/pdf-gen' in '/home/me/project/node_modules/rapipdf/src'
    @ ./node_modules/rapipdf/src/rapipdf.js 35:0-34 240:6-15
    @ ./src/MyComponent.tsx

Could you help me fix it? And how can I use rapipdf in js applications without downloading and including rapipdf-min.js in html?

rowbotman avatar Jul 02 '20 11:07 rowbotman

I was able to work around this issue by using import 'rapipdf/dist/rapipdf-min.js'; instead.

tannerntannern avatar Feb 28 '21 06:02 tannerntannern

@tannerntannern How to call generatePdf?

syksy-map avatar Sep 08 '21 06:09 syksy-map