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)

Preparation

In order to test various APIs without relying on external sources, we will create our own local API. You do not need to know any backend language, nor how to expose an API. In this chapter, we will use a special library that builds an API based on the JSON file that we provide.

So far, we have made a neat application displaying tasks. Now, instead of loading the local data file, let's use our own REST API. Clone the task application to start. (I will be using code from example two in the directory for Chapter 5, Store Patterns.)

Representational State Transfer (REST) is a set of rules that put constraints on web services. One of the crucial requirements is statelessness, which guarantees the server will not store the client's data, but instead rely only on the request data. This should be sufficient enough to send a reply to the client.

In order to create...