react-convert-to-image
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

react-convert-to-image

Plugin to allow the download of React components as html on event trigger with/without preview.

NPM JavaScript Style Guide

Install

    npm install --save react-convert-to-image
    yarn add react-convert-to-image

Usage

  1. Add <div id="download-comp"> to the index.tsx file of your project e.g.

    //... imports here
     import convertToImage from 'react-convert-to-image';
    
    const app = (
      <>
        // any outer wrappers can be used here
        <App />
        <div id="download-comp"></div>
      </>
    );
    
    ReactDOM.render(app, document.getElementById('root'));
    serviceWorker.unregister();
  2. Pass the relevant parameters to the downloadSnapshotOfComponentAs

await convertToImage({
  componentToConvert: <MockComponent />,
  type: 'png'
});

License

MIT © deestewie

Package Sidebar

Install

npm i react-convert-to-image

Weekly Downloads

8

Version

2.0.1

License

MIT

Unpacked Size

363 kB

Total Files

52

Last publish

Collaborators

  • jamdevgirl