React: Up & Running: Building Web Applications

React: Up & Running: Building Web Applications

by Stoyan Stefanov

Paperback

$39.04 $39.99 Save 2% Current price is $39.04, Original price is $39.99. You Save 2%.
View All Available Formats & Editions
Want it by Wednesday, November 21 Order now and choose Expedited Shipping during checkout.

Product Details

ISBN-13: 9781491931820
Publisher: O'Reilly Media, Incorporated
Publication date: 08/07/2016
Pages: 222
Product dimensions: 7.00(w) x 9.10(h) x 0.30(d)

About the Author

Stoyan Stefanov is a Facebook engineer. Previously at Yahoo, he was the creator of the smush.it online image-optimization tool and architect of the YSlow 2.0 performance tool. Stoyan is the author of JavaScript Patterns and Object-Oriented JavaScript, a contributor to Even Faster Web Sites and High-Performance JavaScript, he’s a blogger (phpied.com) and a frequent speaker at conferences including Velocity, JSConf, Fronteers, and many others.

Table of Contents

Preface xi

1 Hello World 1

Setup 1

Hello React World 2

What Just Happened? 4

React.DOM.* 5

Special DOM Attributes 8

React DevTools Browser Extension 9

Next: Custom Components 10

2 The Life of a Component 11

Bare Minimum 11

Properties 13

PropTypes 14

Default Property Values 17

State 18

A Stateful Textarea Component 18

A Note on DOM Events 22

Event Handling in the Olden Days 22

Event Handling in React 24

Props Versus State 24

Props in Initial State: An Anti-Pattern 24

Accessing the Component from the Outside 25

Changing Properties Mid-Flight 27

Lifecycle Methods 28

Lifecycle Example: Log It All 29

Lifecycle Example: Use a Mixin 32

Lifecycle Example: Using a Child Component 33

Performance Win: Prevent Component Updates 36

PureRenderMixin 39

3 Excel: A Fancy Table Component 41

Data First 41

Table Headers Loop 42

Debugging the Console Warning 44

Adding <td> Content 46

How Can You Improve the Component? 48

Sorting 48

How Can You Improve the Component? 50

Sorting UI Cues 50

Editing Data 51

Editable Cell 52

Input Field Cell 54

Saving 54

Conclusion and Virtual DOM Diffs 55

Search 56

State and UI 58

Filtering Content 60

How Can You Improve the Search? 62

Instant Replay 63

How Can You Improve the Replay? 64

An Alternative Implementation? 64

Download the Table Data 65

4 JSX 67

Hello JSX 67

Transpiring JSX 68

Babel 69

Client Side 69

About the JSX transformation 71

JavaScript in JSX 73

Whitespace in JSX 75

Comments in JSX 76

HTML Entities 77

Anti-XSS 78

Spread Attributes 79

Parent-to-Child Spread Attributes 79

Returning Multiple Nodes in JSX 81

JSX Versus HTML Differences 83

No class, What for? 83

Style Is an Object 83

Closing Tags 83

CamelCase Attributes 84

JSX and Forms 84

OnChange Handler 84

Value Versus defaultValue 85

<Textarea> Value 85

<Select> Value 87

Excel Component in JSX 88

5 Setting Up for App Development 89

A Boilerplate App 89

Files and Folders 90

Index.html 91

CSS 92

JavaScript 92

JavaScript: Modernized 93

Installing Prerequisites 96

Node.js 97

Browserify 97

Babel 97

React, etc. 98

Let's Build 98

Transpile JavaScript 98

Package JavaScript 98

Package CSS 99

Results! 99

Windows Version 99

Building During Development 99

Deployment 100

Moving On 101

6 Building an App 103

Whinepad v.0.0.1 103

Setup 103

Start Coding 104

The Components 106

Setup 106

Discover 106

<Button> Component 108

Button.css 109

Button.Js 109

Forms 113

<Suggest> 113

<Rating> Component 116

A <FormInput> "Factory" 119

<Form> 121

<Actions> 124

Dialogs 125

App Config 128

<Excel>: New and Improved 129

<Whinepad> 138

Wrapping It All Up 142

7 Lint, Flow, Test, Repeat 143

Package.json 143

Configure Babel 144

Scripts 144

ESLint 145

Setup 145

Running 145

All the Rules 147

Flow 147

Setup 147

Running 148

Signing Up for Typechecking 148

Fixing <Button> 149

App.js 150

More on Typechecking props and state 152

Export/Import Types 153

Typecasting 154

Invariants 155

Testing 156

Setup 157

First Test 158

First React Test 159

Testing the <Button> Component 160

Testing <Actions> 163

More Simulated Interactions 165

Testing Complete Interactions 167

Coverage 169

8 Flux 173

The Big Idea 174

Another Look at Whinepad 174

The Store 175

Store Events 177

Using the Store in <Whinepad> 179

Using the Store in <Excel> 181

Using the Store in <Form> 182

Drawing the Line 183

Actions 183

CRUD Actions 183

Searching and Sorting 184

Using the Actions in <Whinepad> 186

Using the Actions in <Excel> 188

Flux Recap 190

Immutable 191

Immutable Store Data 192

Immutable Data Manipulation 193

Index 197

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews

React: Up & Running: Building Web Applications 5 out of 5 based on 0 ratings. 1 reviews.
Fieldson More than 1 year ago
The best book of ReactJS so far. Clear and concise and laser-focused on React itself. It doesn't bog you down with complicated setup and webpack and redux and stuff like that from the beginning. The book eventually teaches you modern ECMAScript6 and ESLint and packaging and building, Flow, Flux etc, etc. But to get off the ground all you really need is a text editor and a plain old HTML page. Highly recommended.