Skip to content

Hook doesn't clean up after redirect. #5

@vlad-elagin

Description

@vlad-elagin

Hello!
I've encountered an issue with this hook. I need to conditionally redirect to another route depending on result of polling. It doesn't stop polling after redirect is done.
Here is example of code:

`
const history = useHistory();

const checkPaymentStatus = () => {
return callApi("GET", "/payStatus");
};

const pollingOptions = {
fetchFunc: checkPaymentStatus,
initialState: 1,
delay: 1000,
};

const status = useAPIPolling(pollingOptions);

if (status === 4) {
history.push("/");
}

if (status === 2) {
history.push("/thankyou");
}
`

Any ideas why it happens and how to fix it? btw thank you for this package, it would be great time-saver if not this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions