0

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);
Palaniichuk Dmytro
  • 2,943
  • 12
  • 36
  • 66
  • Possible duplicate of [Open a URL in a new tab (and not a new window)](https://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-and-not-a-new-window) – Apolo Nov 22 '19 at 14:30

1 Answers1

0

See this question: Open page in new window without popup blocking

You need to keep the same context from the user click event.

Mykybo
  • 1,429
  • 1
  • 12
  • 24