Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in iOS #297

Closed
nishivinodbhatt opened this issue Jul 5, 2023 · 3 comments
Closed

Crash in iOS #297

nishivinodbhatt opened this issue Jul 5, 2023 · 3 comments
Labels

Comments

@nishivinodbhatt
Copy link

On iOS, a crash occurs randomly. Attaching a screenshot of the same.
Please provide a solution for this.

Simulator Screenshot - iPhone 14 - 2023-07-05 at 14 22 21

Copy link

stale bot commented Mar 13, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 13, 2024
@Energieman
Copy link

Energieman commented Jun 4, 2024

This error occurs when you have multiple call to create.
You can fix it by using a state to check if document generation has ended. A thousand word is not enough, here is a code example.

const preparePDF = async (callBack = () => {}) => {
try{

  if(generatingDocument){ //here is the solution. If generatingDocument is true, no further call will be made
    return;
  }

  setGeneratingDocument(true) // if  generatingDocument is not true, set it to true so no further calls will be possible until pending process is finished

  await deleteAFile(`file://${generatedFilePath}`)
  const fileName = convertToValidFileName(`${possibleFileName}_${Date.now()}`)

  let options = {
    html: HTMLTemplate(dataArray, userData, {template: currentSkin}),
    fileName,
    height: Number(CONSTANT_MESSAGES.PDFHeight),
    width: Number(CONSTANT_MESSAGES.PDFWidth),
    padding: 0,
    bgColor: '#ffffff'
  };

  let file = await RNHTMLtoPDF.convert(options)
  setGeneratedFilePath(file)
  setGeneratingDocument(false) // close the  generatingDocument check so new call can be successful without crashing your app
  callBack?.(file)

}catch(e){
  callBack?.({}, e)
}

}

This code I provided is not perfect. But should be enough for demostration purpose

@stale stale bot removed the stale label Jun 4, 2024
Copy link

stale bot commented Jan 21, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 21, 2025
@stale stale bot closed this as completed Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants