Skip to content

Latest commit

 

History

History
150 lines (86 loc) · 12.2 KB

debugging.md

File metadata and controls

150 lines (86 loc) · 12.2 KB
title
Debugging

import Video from '~/components/plugins/Video'

Contrary to popular belief, there are sometimes better ways to debug than putting console.log all over your code. There are plenty of tools and libraries that can improve the debugging experience. This document will explain how to use some of the most commonly useful tools.

Prerequisites

  • You should have Expo CLI and Expo client installed as described on the "Installation" page.
  • It's usually easier to test and debug using a simulator, so we recommend setting up the iOS Simulator and/or the Android Emulator before continuing.

Errors and warnings

In development it won't be long before you encounter a "Redbox" error or "Yellowbox" warning.

Redbox errors will show when a fatal error has occurred that prevents your app from running. Warnings will show to let you know of a possible issue that you should probably look into before shipping your app.

You can also create warnings and errors on your own with console.warn("Warning message") and console.error("Error message"). Another way to trigger the redbox is to throw an error and not catch it: throw Error("Error message").

Redbox errors and stack traces

When you encounter an error during development, you will be shown the error message, as well as the "stacktrace," which is a report of the recent calls your application made or was making when it crashed. This stacktrace is shown both in your terminal and in the Expo client app.

This stacktrace is extremely valuable since it gives you the location the error comes from. For example, in the following clip we know that the error came from the file LinksScreen.js on line 10 and column (character) 15.