1

I'm making a request to an API that creates a PDF file on my public folder. After getting response react automatically re-renders the page and ignores everything else to do.

I need to redirect to another page with the name of the generated PDF but re-renders the same page.

API.post('some_url', formData) //this creates a pdf file on public folder
        .then(res => {
          //Ignores redirection
          this.props.history('other_page', res.pdf_name)
        })

I found that the problem was creating the pdf file by trial and error, and when pasting manually a file in the public folder it automatically re-renders the page where i'm currently.

How can i prevent this behavior?

1
  • 2
    Are you using some kind of dev server that automatically re-renders on file changes. ?? if so you need to skip watch the folder you are creating the pdf Commented May 9, 2020 at 5:11

1 Answer 1

1

As suggested by Panther it was my dev server. I used create-react-app for the project, so looking up on how to disable hotreload i stumble onto this answer and it worked.

Thanks for the heads up.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.