2.0.1 • Published 1 year ago
react-convert-to-image v2.0.1
react-convert-to-image
Plugin to allow the download of React components as html on event trigger with/without preview.
Install
npm install --save react-convert-to-image
yarn add react-convert-to-image
Usage
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();
Pass the relevant parameters to the downloadSnapshotOfComponentAs
await convertToImage({
componentToConvert: <MockComponent />,
type: 'png'
});
License
MIT © deestewie