I've got a component where I click and should open new window with response url, In my case I'm waiting for a response and success complete and then hit this open link. HOw to avoid popup browes's blocks
....
const generateCoPayCardTest = () => {
if (!completed) {
generateCoPayCard({
patientId,
pharmacyName
});
return;
}
openNewWindow({ url: data.copay_pdf_url });
};
useEffect(() => {
if (completed) openNewWindow({ url: data.copay_pdf_url });
}, [completed]);
...
<LinkButton onClick={() => generateCoPayCardTest()} />
Also I have open window function
export const openNewWindow = ({ url, features = ['noopener', 'noreferrer'] }) =>
window.open(url, '', features);