Closed pthieu closed 1 year ago
const container = document.createElement('div')
container.style.opacity = '0'
container.style.position = 'fixed'
document.body.appendChild(container)
const root = document.createElement('div')
container.appendChild(root)
const reactRoot = ReactDOM.createRoot(root)
// 👇🏻
reactRoot.render(<div ref={ onDidMount }>Hello, world</div>)
function onDidMount() {
modernScreenshot.domToPng(root).then(dataUrl => {
const link = document.createElement('a')
link.download = 'screenshot.png'
link.href = dataUrl
link.click()
})
}
thanks, had to modify slightly but this works migrating over to this library!
I would like to take a list of data and render it in the background to generate images.
I have an array of data like this:
I would like to loop through each item in the array and pass the data into a React element like:
Is this possible?