Try again, here is the latest version 3.0.2 of react-to-print:
import { useReactToPrint } from 'react-to-print';
const handlePrint = useReactToPrint({
content: () => componentRef?.current,
documentTitle: 'title',
onAfterPrint: () => {}
});