1
0
mirror of synced 2025-12-23 11:54:18 -05:00
Files
docs/components/PrintAction.tsx

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 })
}