* import javascript files directly * move globally required js to _app * fix: js initialization * set next env for tests
17 lines
329 B
TypeScript
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 })
|
|
}
|