Skip to Main Content
Next.js Quick Start Guide
book

Next.js Quick Start Guide

by Kirill Konshin
July 2018
Intermediate to advanced content levelIntermediate to advanced
164 pages
3h 15m
English
Packt Publishing
Content preview from Next.js Quick Start Guide

Error handling

Any application is prone to runtime errors. These could be various kinds of errors: caused by bugs, unexpected input, validation errors, poor network connectivity, or server errors. Lots of them. A well-designed app must not silently stop working or display an ugly error message with tons of irrelevant technical information. Instead, it must always display some meaningful error information, short and simple, and provide tips on how to solve the problem.

There are various approaches to error handling in React apps; let’s review them. As an example, we will look at a failed network request.

First, and simplest, is to store the error in the state of the component. Whenever we make a server request, we can surround it in a try-catch ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Create React App 2 Quick Start Guide

Create React App 2 Quick Start Guide

Brandon Richey
React Cookbook

React Cookbook

David Griffiths, Dawn Griffiths
Test-Driven React

Test-Driven React

Trevor Burnham

Publisher Resources

ISBN: 9781788993661Supplemental Content