Create react screenshot
hook which allows to create screenshots
Install
npm install --save use-react-screenshot
Examples
See this [codesandbox playground] or /example
folder if you want to play with hook.
Usage
A simple usage which allows you to place screenshot image in the page.
import React, { createRef, useState } from 'react'
import { useScreenshot } from 'use-react-screenshot'
export default () => {
const ref = createRef(null)
const [image, takeScreenShot] = useScreenshot()
const getImage = () => takeScreenShot(ref.current)
return (
<div>
<div>
<button style={{ marginBottom: '10px' }} onClick={getImage}>
Take screenshot
</button>
</div>
<img width={width} src={image} alt={'ScreenShot'} />
<div ref={ref}>
<h1>use-react-screenshot</h1>
<p>
<strong>hook by @vre2h which allows to create screenshots</strong>
</p>
</div>
</div>
)
}
License
MIT © vre2h
This hook is created using create-react-hook.