“React 18: Design Patterns and Best Practices” [BOOK REVIEW]

Published on 8/25/2023, 12:00:00 AM

There are a lot of resources on React on the Internet, but when it comes to the best practices and design patterns, you can feel some information overload. That’s where a book by Carlos Santana Roldan comes in - you won't need to look further; you have everything in one place.

“React 18: Design Patterns and Best Practices” was released only a few weeks ago, and thanks to Packt, I got my review copy pretty fast. The book contains 17 chapters over almost 500 pages and covers many topics, including TypeScript, GraphQL, React Hooks, MonoRepo architecture, and Server Side Rendering.

Opened book

In the introduction, the author states that this book is aimed at people with intermediate experience with React and JavaScript. If that’s the case, I’m pretty surprised with the choice of topics, especially in the first few chapters. Chapters 1 through 3 contain absolute React and TypeScript fundamentals, more suited for a total beginner, I’d say. You learn how to start a React project and what TypeScript and JSX are. Like I said - basic stuff.

It gets more interesting in the following chapters. Chapters 4-11 present you with the most popular design patterns and practices in JavaScript and their implementation in the React ecosystem. You’ll learn, for example, about higher-order components, handling events, and refs. There’s also a whole chapter on CSS and, what’s important, it also contains basics of styled-components so you’ll get the broader picture for CSS creation in React projects.

React Hooks and Router also get their chapters. Both act as an introduction to using them and provide some best practices based on simple examples. Unfortunately, I feel like the author could elaborate more on those topics. The hooks topic is nearly 40 pages, but there’s a lot of code, so the actual “content” is much shorter. Again, this works well as an introduction, but if this book is for intermediate developers, it’s mostly the apparent stuff we are getting. Don’t get me wrong; it’s written well, but there was potential to make it more intermediate-advanced and developer-friendly.

Opened book

The chapter on Server-side Rendering was one of the most valuable for me. As a Next.js enthusiast, I wasn't aware that some of the features in Next.js 13 come not from Next but from React 18 (React Server Components, for example). The chapter presents best practices for implementing data fetching and setting up SSR without using any other frameworks. It also briefly introduces Next.js, which for me wasn't anything new, but I see the value for developers focused on pure React.

I liked the author's approach to presenting GraphQL. We got a great example of how to use it, how it works, and the most critical parts. I think it's also the longest chapter, but a lot of code is involved, so that's probably why. I don't mind extensive code listings as long as they clearly explain the topic - and those here definitely do that.

Next up was MonoRepos. I’m used to implementing MonoRepo architecture with Lerna, so I was surprised that this name didn't even occur once in this chapter. But it is understandable - the author describes different solutions like npm workspaces, which are solutions he's more familiar with. We also get an example that helps us understand the ideas behind MonoRepos and the critical implementation details when using this approach.

Front page

The chapter on performance was a big letdown for me. I expected more in-depth tips to make our web app performant, but all I got can be described in one simple sentence - “Use proper keys.” Too bad.

The last two chapters revolve around testing and deployment. They present those topics reasonably well on an introductory level, but again, we get a lot of screenshots and listings and not this much actual content.

So, to summarize, is it worth getting “React 18: Design Patterns and Best Practices”? It depends. If you are a beginner React developer, you’ll find a lot of helpful information here. If you worked with React for some time, you’ll get some new knowledge, but it will mostly be an introduction and an invitation to do more research on your own. If you are an experienced React developer, most of the stuff won’t be new. But my final grade is from the perspective of the first two groups, as this book is advertised for those specific people. So, I see it as a strong four stars out of 5.

Get in touch

You can find me and contact me the following ways: