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 kind of 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” had its release 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 goes through a plethora of topics including TypeScript, GraphQL, React Hooks, MonoRepo architecture, and Server Side Rendering.
React Hooks and Router also get their chapters. Both act as an introduction to using them and also provide some best practices based on simple examples. Unfortunately, I feel like the author could elaborate more on those topics. The whole hooks topic is contained on 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 devs - it’s mostly the obvious stuff that we are getting. Don’t get me wrong, it’s written really well, but there was potential to make it more intermediate-advanced developer-friendly.
The chapter on Server-side Rendering was one of the most valuable for me. As a Next.js enthusiast, I wasn't really 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 gives a brief introduction to Next.js which for me wasn't anything new, but I see the value for developers focused on pure React.
I really liked the author's approach to presenting GraphQL. We got a great example of how to use it, how it works and what are the most important parts. I think it's also the longest chapter, but there's a lot of code involved so that's probably why. I don't mind big 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 a bit surprised that this name didn't even occur once in this chapter. But it is understandable - the author describes different solutions like npm workspaces, solutions he's more familiar with. We also get an example that helps us understand the ideas behind MonoRepos and the important implementation details when using this approach.
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 fairly well on an introductory level, but again we get a lot of screenshots and listings, and not this much actual content.
So to briefly summarize - is it worth it to get “React 18: Design Patterns and Best Practices”? It depends. If you are a beginner React developer you’ll find a lot of useful 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 then most of the stuff won’t be new to you. 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 4 stars out of 5.