1
0
mirror of synced 2025-12-22 11:26:57 -05:00
Files
docs/components/PrintAction.tsx
Mike Surowiec e377d74419 React: import necessary javascripts directly (#20001)
* import javascript files directly

* move globally required js to _app

* fix: js initialization

* set next env for tests
2021-06-21 21:55:49 +00:00

17 lines
329 B
TypeScript

import React from 'react'
type Props = {
children: React.ReactElement
}
export function PrintAction({ children }: Props) {
const onClick = () => {
try {
document.execCommand('print', false)
} catch (e) {
window.print()
}
}
return React.cloneElement(React.Children.only(children), { onClick })
}