Beginning ReactJS Foundations Building User Interfaces with ReactJS An Approachable Guide 1st Edition Chris Minnick pdf download
Beginning ReactJS Foundations Building User Interfaces with ReactJS An Approachable Guide 1st Edition Chris Minnick pdf download
https://ebookmeta.com/product/beginning-reactjs-foundations-
building-user-interfaces-with-reactjs-an-approachable-guide-1st-
edition-chris-minnick-2/
https://ebookmeta.com/product/beginning-reactjs-foundations-
building-user-interfaces-with-reactjs-an-approachable-guide-1st-
edition-chris-minnick/
https://ebookmeta.com/product/learn-javafx-17-building-user-
experience-and-interfaces-with-java-sharan/
https://ebookmeta.com/product/strategic-communication-and-ai-
public-relations-with-intelligent-user-interfaces-1st-edition-
simon-moore/
https://ebookmeta.com/product/beneath-the-surface-1st-edition-m-
a-church/
Lectures on Stochastic Programming Modeling and Theory
2nd Edition Alexander Shapiro
https://ebookmeta.com/product/lectures-on-stochastic-programming-
modeling-and-theory-2nd-edition-alexander-shapiro/
https://ebookmeta.com/product/hangman-island-1st-edition-kate-
rhodes/
https://ebookmeta.com/product/fighting-tooth-nail-kings-gym-
book-2-1st-edition-shaw-hart/
https://ebookmeta.com/product/osint-techniques-resources-for-
uncovering-online-information-10th-edition-2023-michael-bazzell/
https://ebookmeta.com/product/pdz-mediated-interactions-jean-
paul-borg/
Compressor Handbook Principles and Practice 2nd Edition
Tony Giampaolo
https://ebookmeta.com/product/compressor-handbook-principles-and-
practice-2nd-edition-tony-giampaolo/
Table of Contents
COVER
TITLE PAGE
INTRODUCTION
WHY THIS BOOK?
WHAT'S COVERED IN THIS BOOK?
WHAT'S NOT COVERED?
PREREQUISITES
INSTALLING REQUIRED DEPENDENCIES
READER SUPPORT FOR THIS BOOK
1 Hello, World!
REACT WITHOUT A BUILD TOOLCHAIN
INTERACTIVE “HELLO, WORLD” WITH CREATE REACT
APP AND JSX
SUMMARY
2 The Foundation of React
WHAT'S IN A NAME?
UI LAYER
VIRTUAL DOM
THE PHILOSOPHY OF REACT
SUMMARY
3 JSX
JSX IS NOT HTML
WHAT IS JSX?
SYNTAX BASICS OF JSX
SUMMARY
4 All About Components
WHAT IS A COMPONENT?
COMPONENTS VS. ELEMENTS
BUILT-IN COMPONENTS
USER-DEFINED COMPONENTS
TYPES OF COMPONENTS
REACT COMPONENT CHILDREN
THE COMPONENT LIFECYCLE
RENDERING COMPONENTS
COMPONENT TERMINOLOGY
SUMMARY
5 React DevTools
INSTALLATION AND GETTING STARTED
INSPECTING COMPONENTS
EDITING COMPONENT DATA IN DEVTOOLS
WORKING WITH ADDITIONAL DEVTOOLS
FUNCTIONALITY
PROFILING
SUMMARY
6 React Data Flow
ONE-WAY DATA FLOW
PROPS
REACT STATE
CONVERTING TO CLASS COMPONENTS
SUMMARY
7 Events
HOW EVENTS WORK IN REACT
WHAT IS SYNTHETICEVENT?
USING EVENT LISTENER ATTRIBUTES
THE EVENT OBJECT
SUPPORTED EVENTS
EVENT HANDLER FUNCTIONS
SUMMARY
8 Forms
FORMS HAVE STATE
CONTROLLED INPUTS VS. UNCONTROLLED INPUTS
LIFTING UP INPUT STATE
USING UNCONTROLLED INPUTS
USING DIFFERENT FORM ELEMENTS
PREVENTING DEFAULT ACTIONS
SUMMARY
9 Refs
WHAT REFS ARE
HOW TO CREATE A REF IN A CLASS COMPONENT
HOW TO CREATE A REF IN A FUNCTION COMPONENT
USING REFS
CREATING A CALLBACK REF
WHEN TO USE REFS
WHEN NOT TO USE REFS
EXAMPLES
SUMMARY
10 Styling React
THE IMPORTANCE OF STYLES
IMPORTING CSS INTO THE HTML FILE
USING PLAIN OLD CSS IN COMPONENTS
WRITING INLINE STYLES
CSS MODULES
CSS-IN-JS AND STYLED COMPONENTS
SUMMARY
11 Introducing Hooks
WHAT ARE HOOKS?
WHY WERE HOOKS INTRODUCED?
RULES OF HOOKS
THE BUILT-IN HOOKS
WRITING CUSTOM HOOKS
LABELING CUSTOM HOOKS WITH USEDEBUGVALUE
FINDING AND USING CUSTOM HOOKS
SUMMARY
12 Routing
WHAT IS ROUTING?
HOW ROUTING WORKS IN REACT
USING REACT ROUTER
REACT ROUTER HOOKS
SUMMARY
13 Error Boundaries
THE BEST LAID PLANS
WHAT IS AN ERROR BOUNDARY?
IMPLEMENTING AN ERROR BOUNDARY
WHAT CAN'T AN ERROR BOUNDARY CATCH?
SUMMARY
14 Deploying React
WHAT IS DEPLOYMENT?
BUILDING AN APP
HOW IS A DEPLOYED APP DIFFERENT?
DEVELOPMENT MODE VS. PRODUCTION
PUTTING IT ON THE WEB
SUMMARY
15 Initialize a React Project from Scratch
BUILDING YOUR OWN TOOLCHAIN
HOW WEBPACK WORKS
AUTOMATING YOUR BUILD PROCESS
STRUCTURING YOUR SOURCE DIRECTORY
SUMMARY
16 Fetching and Caching Data
ASYNCHRONOUS CODE: IT'S ALL ABOUT TIMING
JAVASCRIPT NEVER SLEEPS
WHERE TO RUN ASYNC CODE IN REACT
WAYS TO FETCH
GETTING DATA WITH FETCH
GETTING DATA WITH AXIOS
USING WEB STORAGE
SUMMARY
17 Context API
WHAT IS PROP DRILLING?
HOW CONTEXT API SOLVES THE PROBLEM
COMMON USE CASES FOR CONTEXT
WHEN NOT TO USE CONTEXT
COMPOSITION AS AN ALTERNATIVE TO CONTEXT
EXAMPLE APP: USER PREFERENCES
SUMMARY
18 React Portals
WHAT IS A PORTAL?
COMMON USE CASES
SUMMARY
19 Accessibility in React
WHY IS ACCESSIBILITY IMPORTANT?
ACCESSIBILITY BASICS
IMPLEMENTING ACCESSIBILITY IN REACT
COMPONENTS
SUMMARY
20 Going Further
TESTING
SERVER-SIDE RENDERING
PEOPLE TO FOLLOW
USEFUL LINKS AND RESOURCES
SUMMARY
INDEX
COPYRIGHT
DEDICATION
ABOUT THE AUTHOR
ABOUT THE TECHNICAL EDITOR
ACKNOWLEDGMENTS
END USER LICENSE AGREEMENT
List of Tables
Chapter 4
TABLE 4-1: HTML Elements Supported by React
TABLE 4-2: Functions vs. Classes
Chapter 6
TABLE 6-1: Comparing props and state
Chapter 7
TABLE 7-1: Events Supported by React
Chapter 12
TABLE 12-1: Properties and Methods of history
List of Illustrations
Introduction
FIGURE I-1: VS Code
FIGURE I-2: Download VS Code
FIGURE I-3: The VS Code welcome screen
FIGURE I-4: The VS Code Command Palette
FIGURE I-5: Creating a new file using the Command
Palette
FIGURE I-6: Using Emmet to save typing
FIGURE I-7: Client-side React and server-side Node
FIGURE I-8: Development, client-side, and server-side
FIGURE I-9: Minification
FIGURE I-10: Transpiling example
FIGURE I-11: Module bundling
FIGURE I-12: The VS Code Terminal
FIGURE I-13: Checking that npm is installed
FIGURE I-14: Chrome DevTools
FIGURE I-15: React Developer Tools Components view
FIGURE I-16: The default Create React App boilerplate
Chapter 1
FIGURE 1-1: The React CDN Links
FIGURE 1-2: Hello, World running in a browser
FIGURE 1-3: The finished interactive Hello, World
component!
Chapter 2
FIGURE 2-1: The MVC pattern
FIGURE 2-2: React and ReactDOM
FIGURE 2-3: How the Virtual DOM works
FIGURE 2-4: How the web works
Chapter 3
FIGURE 3-1: Trying out Babel on the web
Chapter 4
FIGURE 4-1: A tree of react components
FIGURE 4-2: Using state immediately after calling
setState() may produce une...
FIGURE 4-3: The result of rendering FigureList
FIGURE 4-4: Rendering the ThingsILike component
FIGURE 4-5: The component lifecycle
FIGURE 4-6: Incrementing a counter
FIGURE 4-7: The result of attempting to call setState on an
unmounted compon...
FIGURE 4-8: Hello, React Native
Chapter 5
FIGURE 5-1: The React Bookstore sample app
FIGURE 5-2: The Chrome Developer Tools with React
DevTools installed
FIGURE 5-3: The React DevTools Components tab
FIGURE 5-4: The component tree with ProductList
collapsed
FIGURE 5-5: Creating new CartItem children
FIGURE 5-6: Searching for components containing “c”
FIGURE 5-7: Searching for components starting with “c”
FIGURE 5-8: React DevTools' View Settings
FIGURE 5-9: The component tree view with the default
filter disabled
FIGURE 5-10: The React DevTools Select tool
FIGURE 5-11: Viewing component details
FIGURE 5-12: Attempting to add an out-of-range ID to the
cart
FIGURE 5-13: Logging component data to the console
FIGURE 5-14: The Flamegraph chart
FIGURE 5-15: Viewing the Ranked chart
FIGURE 5-16: Ranked chart after optimizing
Chapter 6
FIGURE 6-1: Unidirectional data flow
FIGURE 6-2: Bidirectional data flow
FIGURE 6-3: Data flowing in one direction
FIGURE 6-4: Changing local variables doesn't update the
view
FIGURE 6-5: Local variable and props confusion
FIGURE 6-6: Passing the wrong prop type
FIGURE 6-7: PropTypes displaying a warning
FIGURE 6-8: The not-renderable error message
FIGURE 6-9: PropTypes tell which attribute caused the
error
FIGURE 6-10: Failing PropTypes.element validation
FIGURE 6-11: A custom PropType validator failing
FIGURE 6-12: The result of clicking the CounterClass
button
FIGURE 6-13: The fixed counter class
FIGURE 6-14: A reminders app
FIGURE 6-15: The first round static version
FIGURE 6-16: A static version of the Reminders app
FIGURE 6-17: Cannot read property
FIGURE 6-18: Cannot read property ‘map' of undefined
FIGURE 6-19: Displaying the default prop
FIGURE 6-20: The initial render of the Reminders app
FIGURE 6-21: Adding Reminders to the list
FIGURE 6-22: Checking and unchecking isComplete
checkboxes
Chapter 7
FIGURE 7-1: Viewing the properties of a SyntheticEvent
FIGURE 7-2: The NativeEvent properties
Chapter 8
FIGURE 8-1: Controlled and uncontrolled inputs
FIGURE 8-2: Rendering an uncontrolled input
FIGURE 8-3: Form input often affects other components
Chapter 9
FIGURE 9-1: The TextReader component
FIGURE 9-2: Selecting text and displaying a temporary
message
Chapter 10
FIGURE 10-1: Cascading styles from parent to child
Chapter 11
FIGURE 11-1: Wrapper hell
FIGURE 11-2: Passing a setter function as a prop
FIGURE 11-3: Starting a new timer with each render
FIGURE 11-4: Running an effect only after mounting
FIGURE 11-5: Performing an asynchronous request using
useEffect
FIGURE 11-6: Unnecessary renders warning due to a
function dependency
FIGURE 11-7: Testing referential equality
FIGURE 11-8: Inspecting a custom hook
FIGURE 11-9: Viewing a Custom Hook's debug value
Chapter 12
FIGURE 12-1: How the web works
FIGURE 12-2: JavaScript routing
FIGURE 12-3: Changing routes and viewing the
window.location.href property
FIGURE 12-4: React Router can't be used for external
linking
FIGURE 12-5: Navigation links indicate the current position
FIGURE 12-6: A navigation menu with sub-items
FIGURE 12-7: Partial matches activate the active style
FIGURE 12-8: Using the exact attribute on NavLink
components
FIGURE 12-9: Multiple routes can match the URL
FIGURE 12-10: Add the exact attribute to Routes to restrict
matching
FIGURE 12-11: Modifying the current location
FIGURE 12-12: Dynamic link and path attributes with the
match object propert...
Chapter 13
FIGURE 13-1: A crashed React app
FIGURE 13-2: A diagram of a typical UI
FIGURE 13-3: An uncaught error
FIGURE 13-4: Handling an error with an error boundary
FIGURE 13-5: Rendering a fallback UI
FIGURE 13-6: Viewing the error and info parameters in the
console
FIGURE 13-7: Add a log source
FIGURE 13-8: The Customer Token link in Loggly
FIGURE 13-9: Viewing caught errors in Loggly
FIGURE 13-10: Providing a reset option in the error
boundary
Chapter 14
FIGURE 14-1: The build directory
FIGURE 14-2: The minified and compiled index.html
FIGURE 14-3: Running a built app from the filesystem
FIGURE 14-4: Development vs. production in the
Developer Tools
FIGURE 14-5: Click the New site from Git button
FIGURE 14-6: Choose your Git provider
FIGURE 14-7: Choose a repository
FIGURE 14-8: A deployed React app
FIGURE 14-9: Domain management in Netlify
Chapter 15
FIGURE 15-1: Attempting to load index.js without
compiling
FIGURE 15-2: JSX requires a loader
FIGURE 15-3: The working React app
FIGURE 15-4: Starting the configuration wizard
FIGURE 15-5: Automatically fixable errors or warnings
FIGURE 15-6: No tests found
FIGURE 15-7: Test passed
FIGURE 15-8: Grouping by file type
FIGURE 15-9: Grouping by features
Chapter 16
FIGURE 16-1: Executing asynchronous JavaScript
FIGURE 16-2: How asynchronous tasks are handled
FIGURE 16-3: Remembering a user with Web Storage
FIGURE 16-4: Viewing Local Storage in Chrome Developer
Tools
Chapter 17
FIGURE 17-1: Using a component outside of its Context
FIGURE 17-2: A user preferences component with Context
Chapter 18
FIGURE 18-1: Portals enable modal dialogs
FIGURE 18-2: Rendering the SalesChart component
FIGURE 18-3: Inspecting an app with a Portal in Chrome
Developer Tools
FIGURE 18-4: Inspecting an app with a Portal in React
Developer Tools
FIGURE 18-5: Rendering a modal without using React
Portals can have unexpect...
FIGURE 18-6: The opened modal
FIGURE 18-7: A checkout form with help links
Chapter 20
FIGURE 20-1: The Flux pattern
FIGURE 20-2: Data flow in a Redux application
BEGINNING
ReactJS Foundations
Building User Interfaces with
ReactJS
AN APPROACHABLE GUIDE
Chris Minnick
Discovering Diverse Content Through
Random Scribd Documents
The craft most frequently practised by my ancestors seems {5} to
have been that of a goldsmith, although several are believed to have
practised less dignified trades.
In the time of Henry the Eighth one of my ancestors, together
with a hundred men, were taken prisoners at the siege of Calais.
When William the Third landed in Torbay, another ancestor of
mine, a yeoman possessing some small estate, undertook to
distribute his proclamations. For this bit of high treason he was
rewarded with a silver medal, which I well remember seeing, when I
was a boy. It had descended to a very venerable and truthful old
lady, an unmarried aunt, the historian of our family, on whose
authority the identity of the medal I saw with that given by King
William must rest.
Another ancestor married one of two daughters, the only children
of a wealthy physician, Dr. Burthogge, an intimate friend and corres‐
pondent of John Locke.
〈A WILD ANCESTOR.〉
Early Passion for inquiry and inquisition into Toys — Lost on London Bridge —
Supposed value of the young Philosopher — Found again — Strange Coincidence in
after-years — Poisoned — Frightened a Schoolfellow by a Ghost — Frightened himself
by trying to raise the Devil — Effect of Want of Occupation for the Mind — Treasure-
trove — Death and Non-appearance of a Schoolfellow.
When about five years old, I was walking with my nurse, who
had in her arms an infant brother of mine, across London Bridge,
holding, as I thought, by her apron. I was looking at the ships in the
river. On turning round to speak to her, I found that my nurse was
not there, and that I was alone upon London Bridge. My mother had
always impressed upon me the necessity of great caution in passing
any street-crossing: I went on, therefore, quietly until I reached
Tooley Street, where I remained watching the passing vehicles, in
order to find a safe opportunity of crossing that very busy street.
〈THE CRIER OFFERS A REWARD.〉
In the mean time the nurse, having lost one of her charges, had
gone to the crier, who proceeded immediately to call, by the ringing
of his bell, the attention of the public to the fact that a young philos‐
opher was lost, and to the still more important fact that five shillings
would be the reward of his fortunate discoverer. I well remember
sitting on the steps of {9} the door of the linendraper’s shop on the
opposite corner of Tooley Street, when the gold-laced crier was
making proclamation of my loss; but I was too much occupied with
eating some pears to attend to what he was saying.
The fact was, that one of the men in the linendraper’s shop,
observing a little child by itself, went over to it, and asked what it
wanted. Finding that it had lost its nurse, he brought it across the
street, gave it some pears, and placed it on the steps at the door:
having asked my name, the shopkeeper found it to be that of one of
his own customers. He accordingly sent off a messenger, who
announced to my mother the finding of young Pickle before she was
aware of his loss.
Those who delight in observing coincidences may perhaps
account for the following singular one. Several years ago when the
houses in Tooley Street were being pulled down, I believe to make
room for the new railway terminus, I happened to pass along the
very spot on which I had been lost in my infancy. A slate of the
2
largest size, called a Duchess, was thrown from the roof of one of
the houses, and penetrated into the earth close to my feet.
2 There exists an aristocracy even amongst slates, perhaps from their occupying
the most elevated position in every house. Small ones are called Ladies, a larger
size Countesses, and the biggest of all are Duchesses.
The other event, which I believe happened some time after the
one just related, is as follows. I give it from memory, as I have
always repeated it.
〈YOUNG PHILOSOPHER POISONED.〉
A rabbit,
An owl,
A black cat, very frequently,
A raven,
A man with a cloven foot, also frequent.
After long thinking over the subject, although checked by a belief
that the inquiry was wicked, my curiosity at length over-balanced my
fears, and I resolved to attempt to raise the devil. Naughty people, I
was told, had made written compacts with the devil, and had signed
them with their names written in their own blood. These had
become very rich and great men during their life, a fact which might
be well known. But, after death, they were described as having
suffered and continuing to suffer physical torments throughout
eternity, another fact which, to my uninstructed mind, it seemed
difficult to prove.
As I only desired an interview with the gentleman in black simply
to convince my senses of his existence, I declined adopting the legal
forms of a bond, and preferred one more resembling that of leaving
a visiting card, when, if not at home, I might expect the satisfaction
of a return of the visit by the devil in person. {12}
〈TRIES TO RAISE THE DEVIL.〉
One night I found a small chain fixed to the lock, and passing
thence into Marryat’s bed. This defeated my efforts for that night,
and I retired to my own bed. The next night {21} I was provided with
a pair of plyers, and unbent one of the links, leaving the two
portions attached to Marryat’s arm and to the lock of the door. This
occurred several times, varying by stouter chains, and by having a
padlock which I could not pick in the dark.
At last one morning I found a chain too strong for the tools I
possessed; so I retired to my own bed, defeated. The next night,
however, I provided myself with a ball of packthread. As soon as I
heard by his breathing that Marryat was asleep, I crept over to the
door, drew one end of my ball of packthread through a link of the
too-powerful chain, and bringing it back with me to bed, gave it a
sudden jerk by pulling both ends of the packthread passing through
the link of the chain.
Marryat jumped up, put out his hand to the door, found his chain
all right, and then lay down. As soon as he was asleep again, I
repeated the operation. Having awakened him for the third time, I
let go one end of the string, and drew it back by the other, so that
he was unable at daylight to detect the cause.
At last, however, I found it expedient to enter into a treaty of
peace, the basis of which was that I should allow Marryat to join the
night party; but that nobody else should be admitted. This continued
for a short time; but, one by one, three or four other boys, friends of
Marryat, joined our party, and, as I had anticipated, no work was
done. We all got to play; we let off fire-works in the play-ground,
and were of course discovered.
〈FOUND OUT.〉
Many boys rose up from their knees—but some fell down again.
Some turned round several times, and then fell. Some turned round
so often that they resembled spinning dervishes. Others were only
more stupid than usual; some complained of being sick; many were
very sleepy; others were sound asleep, and had to be carried to bed;
some talked fast and heroically, two attempted psalmody, but none
listened.
All investigation at the time was useless: we were sent off to bed
as quickly as possible. It was only known that Count Cognac had
married the sweet Miss Treacle, whom all the boys knew and loved,
and who lodged at the grocer’s, in the neighbouring village. But I
believe neither the pedigree of the bridegroom nor his domicile were
ever discovered. It is probable that he was of French origin, and
dwelt in a cellar.
After I left this school I was for a few years under the care of an
excellent clergyman in the neighbourhood of Cambridge. There were
only six boys; but I fear I did not derive from it all the advantage
that I might have done. I came into frequent contact with the Rev.
Charles Simeon, and with many of his enthusiastic disciples. Every