Book Image

Hands-On Design Patterns with React Native

By : Mateusz Grzesiukiewicz
Book Image

Hands-On Design Patterns with React Native

By: Mateusz Grzesiukiewicz

Overview of this book

React Native helps developers reuse code across different mobile platforms like iOS and Android. This book will show you effective design patterns in the React Native world and will make you ready for professional development in big teams. The book will focus only on the patterns that are relevant to JavaScript, ECMAScript, React and React Native. However, you can successfully transfer a lot of the skills and techniques to other languages. I call them “Idea patterns”. This book will start with the most standard development patterns in React like component building patterns, styling patterns in React Native and then extend these patterns to your mobile application using real world practical examples. Each chapter comes with full, separate source code of applications that you can build and run on your phone. The book is also diving into architectural patterns. Especially how to adapt MVC to React environment. You will learn Flux architecture and how Redux is implementing it. Each approach will be presented with its pros and cons. You will learn how to work with external data sources using libraries like Redux thunk and Redux Saga. The end goal is the ability to recognize the best solution for a given problem for your next mobile application.
Table of Contents (13 chapters)

What this book covers

Chapter 1, React Component Patterns, is the starting point of our journey. We need to understand the core building blocks of our application: React components. You will learn how to properly use presentational and container components.

Chapter 2, View Patterns, will dive into the best approaches into writing view code. You will learn the patterns that decouple view layer from the rest of the app. Also, in this chapter we learn about the basics of React Native: its most important components that are available out of the box. For the first time, our application code will be automatically tested by tooling such as Linter.

Chapter 3, Styling Patterns, is a chapter dedicated to design patterns built around styling. You get a look at the patterns that mobile designers need to follow. On top of that, we will learn Flexbox pattern and learn how to properly create and measure animations in React Native.

Chapter 4, Flux Architecture, finally looks at the architecture. Flux will enable us to scale our frontend code much more easily. For the first time, we will introduce Dispatcher and Stores into our application.

Chapter 5, Store Patterns, focuses on one important part of Flux: Store. You will learn about the Redux and Mobx state management libraries. By the end of the chapter, you will know how to make Store your application's single source of truth.

Chapter 6, Data Transfer Patterns, walks you through patterns that involve so-called side effects. We will use the local server and the API that our React Native code will consume. You will learn how to decouple such processes from the main application code using Redux Thunk and Redux Saga libraries

Chapter 7, Navigation Patterns, shows you the difficult part of the mobile application: navigation. We will dive into cross-platform problems and see how to handle them using either React Navigation or React Native Navigation.

Chapter 8, JavaScript and ECMAScript Patterns, starts with the JavaScript iterator pattern and then walks you through useful functions within JavaScript, ECMAScript, and in a Ramda library. After all that, we discuss some of the functional approaches that are related to the next chapter.

Chapter 9, Elements of Functional Programming Patterns, explores the unique world of Functional Programming patterns. Some of them are really famous in React and React Native applications. This chapter aims to explain why and helps you make a right decision if you should take more Functional Programming techniques into your project.

Chapter 10, Managing Dependencies, draws your attention to dependency injection, and how to avoid usage of Singleton pattern. You will learn about the React context API and see how libraries have been leveraging dependency injection in the past.

Chapter 11, Type Checking Patterns, teaches you how to type your application. We will do a walk-through of TypeScript's capabilities. By the end, you will be able to type the whole application. You will learn what nominal and structural typing are.