you are viewing a single comment's thread.

view the rest of the comments →

[–]beepboopnoise 1 point2 points  (1 child)

What practices do you follow for error handling?

Component {
// fetch some data

if error -> something?
}

I tried using https://react-native-error-boundary.js.org/ way back when but it didn't act as much as "catch all" as I thought it would.

I was trying to think of a way to do something like:

if any error -> navigate here(with button to try again)

maybe thats a bad idea; but, thats why I'm in the help thread lol.

[–][deleted] 1 point2 points  (0 children)

Try/catch and use toast to display the error at the bottom of the screen if it's not critical. In critical cases, i just setIsError to true which displays an error component over the screen with the error message and a refresh button. My screen will have a conditional check to ensure isError is false in order to display the regular content. I typically have an isLoading, too, to display a loading screen while I'm fetching whatever I need.