Book Image

React Components

By : Christopher Pitt
Book Image

React Components

By: Christopher Pitt

Overview of this book

The reader will learn how to use React and its component-based architecture in order to develop modern user interfaces. A new holistic way of thinking about UI development will establish throughout this book and the reader will discover the power of React components with many examples. After reading the book and following the example application, the reader has built a small to a mid-size application with React using a component based UI architecture. The book will take the reader through a journey to discover the benefits of component-based user interfaces over the classical MVC architecture. Throughout the book, the reader will develop a wide range of components and then bring them together to build a component-based UI. By the end of this book, readers would have learned several techniques to build powerful components and how the component-based development is beneficial over regular web development.
Table of Contents (17 chapters)
React Components
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Preface

React is a fascinating new take on traditional frontend development. It has taken the JavaScript community by storm and has inspired sweeping changes in a number of existing JavaScript application frameworks and architectures.

Unfortunately, there still aren't many examples of great architecture. Most tutorials and books focus on small components and examples, leaving the question of larger applications and component hierarchies unanswered. That is what this book seeks to change.

What this book covers

Chapter 1, Thinking in Components, looks at the need to think of entire interfaces as a composition of small components and how to build them using modern ES6 JavaScript.

Chapter 2, Working with Properties and State, takes a comprehensive look at many aspects of property and state management, sharing a few more ES6 tricks along the way.

Chapter 3, Saving and Communicating Data, looks at reactive programming using event emitters and unidirectional flow of data.

Chapter 4, Styling and Animating Components, takes a look at how components can be styled and animated both inline and using stylesheets.

Chapter 5, Going Material!, explores material design and applies what you learn to our set of components.

Chapter 6, Changing Views, looks at ways of transitioning between different views with routing and animation.

Chapter 7, Rendering on the Server, takes a look at the process of rendering components through nodes and some ways of structuring server-side application code.

Chapter 8, React Design Patterns, explores different architectures such as Flux and Redux.

Chapter 9, Thinking of Plugins, looks at how to build components with dependency injection and extension points.

Chapter 10, Testing Components, explores various ways of ensuring that components are error-free and that changes to parts of an application don't have cascading effects on other parts.

What you need for this book

The following hardware is recommended for maximum enjoyment:

  • Any modern computer with Linux, Mac OS, or Windows.

All software mentioned in this book are free of charge and can be downloaded from the Internet.

Who this book is for

This book is ideal for developers who are familiar with the basics of React and are looking for a guide to build a wide range of components as well as develop component-driven UIs.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We need to register a default set of tasks, which we set to browserify and uglify."

A block of code is set as follows:

"scripts": {
    "bundle": "browserify -t babelify main.js -o main.dist.js",
    "minify": "..."
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

render() {
    if (this.state.isEditing) {
        return <PageEditor {...this.props} />;
    }

    return <PageView {...this.props} />;
}

Any command-line input or output is written as follows:

$ npm install --save-dev grunt
$ npm install --save-dev grunt-browserify
$ npm install --save-dev grunt-contrib-uglify
$ npm install --save-dev grunt-contrib-watch

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "To get the most out of JSBin, be sure to set the JavaScript dropdown to ES6/Babel and include the ReactJS scripts from CDNJS."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

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

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.