Preface
Nowadays exists tons of JavaScript libraries, frameworks, and tools for Web development. However, we should evaluate each technology to see if it fits for our project requirements. That's why I want to introduce to you React, one of the most powerful libraries to create dynamic UIs. Right now is the most popular library (not a framework) made by Facebook. I have worked with others JS frameworks such as AngularJS (also the new versions Angular 2, 4, 5), Backbone.js, Ember, and Vue.js in different projects but I can tell you that using React I enjoy more to developing new Web applications.
React has changed the way of doing Web applications and combined with Redux, we get a powerful frontend architecture that makes sense not only to experienced developers but also to those who're just starting their frontend journey.
The book introduces all the tools and best practices of React in simple recipes easy to follow, all of the recipes in this book are 100% practical and each one has the necessary code to understand all the important things.
Welcome to a better future and have fun reading and learning from this book.
Who this book is for
The book can be used by any developer who has a basic knowledge of building web applications. Mainly for JavaScript developers but not limited to any other type of devs.
What this book covers
Chapter 1, Working with React, React is a JavaScript library (MIT License) made by Facebook to create interactive UIs. It's used to create dynamic and reusable components. The most powerful thing about React is that can be used in the client, server, mobile applications and even VR applications.
Chapter 2, Conquering Components and JSX, this chapter contains recipes related to how to create components in React. We are going to learn how to create React components (class components, pure components, and functional components) and organize our project structure.
Chapter 3, Handling Events, Binding and Useful React Packages, this chapter contains recipes related to handling events, binding methods in React and we will implement some of the most useful React packages.
Chapter 4, Adding Routes to Our Application with React Router, in this chapter, we are going to learn how to add dynamic routes in our project using React Router v4.
Chapter 5, Mastering Redux, Redux is a predictable state container for JavaScript apps. That means Redux can be used with vanilla JavaScript or frameworks/libraries such as Angular and jQuery. Redux is mainly a library responsible for issuing state updates and responses to actions.
Chapter 6, Creating Forms with Redux Form, Forms are a fundamental part of any web application, and in the following recipes, we are going to learn how to use forms with and without Redux Form.
Chapter 7, Animations with React, Animations are very common in any web application. Since CSS3, animations have become widespread and easy to implement. The most common use of animations are transitions, where you can change CSS properties and define the duration or delay.
Chapter 8, Creating an API with Node.js Using MongoDB and MySQL, Node.js is widely used as a backend for web applications because it is easy to create an API and its performance is better than technologies such as Java, PHP, and Ruby. Usually, the most popular way to use Node.js is by using a framework called Express.
Chapter 9, Apollo and GraphQL, GraphQL is an Application Layer Query Language which can be used with any database, also is an open source (MIT license) created by Facebook. The main difference with REST is that GraphQL does not use endpoints but queries instead and is supported by most of the server languages such as JavaScript (Node.js), Go, Ruby, PHP, Java, Python, and so on.
Chapter 10, Mastering Webpack 4.x, Webpack 4 does not need a configuration file by default. Before in the oldest versions, you must have a configuration file, but of course, if you need to customize Webpack 4 to your project needs, you can still create a configuration file which will be way easier to configure.
Chapter 11, Implementing Server-Side Rendering, Probably you don't need to worry about Server Side Rendering (SSR) if you don't care too much about SEO. Currently, the Googlebot supports Client Side Rendering (CSR), and it can index our site in Google, but if you care about SEO and you are worried about improving the SEO on others Search Engines like Yahoo, Bing or DuckDuckGo then using Server Side Rendering (SSR) is the way to go.
Chapter 12, Testing and Debugging, testing and debugging are very important for any project that wants to have the best quality. Unfortunately, many developers do not care about testing (unit tests) because they think that will reduce the speed of the development and some of them leave it until the end of the project. In my personal experience, I can say that testing since the beginning of the project will save you time because at the end you will have fewer bugs to fix.
Chapter 13, Deploying to Production, now is time to deploy our application to production and show it to the world. In this chapter, you will learn how to deploy our React Application using one of the best cloud services: Digital Ocean.
Chapter 14, Working with React Native, React Native is a framework for building mobile apps using JavaScript and React. Many people think that with React Native you make some "mobile web app" or a "hybrid app" (like Ionic, PhoneGap or Sencha) but you build a native app because React Native converts your React code to Java for Android and Objective-C for iOS apps.
To get the most out of this book
To master React, you need to have a fundamental knowledge of JavaScript and Node.js. The book mostly targets Web developers, and at the time of writing, the following assumptions were made for the reader:
- The reader knows how to install the latest version of Node.js.
- An intermediate developer who can understand JavaScript ES6 syntax.
- Little experience with CLI tools and Node.js syntax.
The book also has a little for Mobile developers (iOS and Android) using React Native, if you are a beginner you should learn how to install Android SDK or the iOS simulator with Xcode.
Download the example code files
You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
- Log in or register at www.packtpub.com.
- Select the
SUPPORT
tab. - Click on
Code Downloads & Errata
. - Enter the name of the book in the
Search
box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
- WinRAR/7-Zip for Windows
- Zipeg/iZip/UnRarX for Mac
- 7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/React-Cookbook. If there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Note
Warnings or important notes appear like this.
Note
Tips and tricks appear like this.
Get in touch
Feedback from our readers is always welcome.
General feedback: Email [email protected]
and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected]
.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected]
with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Reviews
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packtpub.com.