React and React Native - Fifth Edition Mikhail Sakhniukpdf download
React and React Native - Fifth Edition Mikhail Sakhniukpdf download
https://ebookmass.com/product/react-and-react-native-fifth-
edition-mikhail-sakhniuk/
https://ebookmass.com/product/master-react-in-5-days-become-a-react-
expert-in-under-a-week-eric-sarrion/
https://ebookmass.com/product/master-react-in-5-days-become-a-react-
expert-in-under-a-week-eric-sarrion-2/
https://ebookmass.com/product/react-hooks-in-action-meap-03-john-
larsen-larsen/
■■■■■■ ■■ TypeScript■React■Node.js■webpack ■ Docker Frank
Zammetti
https://ebookmass.com/product/%e7%8e%b0%e4%bb%a3%e5%85%a8%e6%a0%88%e5%
bc%80%e5%8f%91-%e4%bd%bf%e7%94%a8-
typescript%e3%80%81react%e3%80%81node-
js%e3%80%81webpack-%e5%92%8c-docker-frank-zammetti/
https://ebookmass.com/product/native-nations-cultures-and-histories-
of-native-north-america/
https://ebookmass.com/product/pharmcards-fifth-edition/
https://ebookmass.com/product/stuttering-fifth-edition/
Every effort has been made in the preparation of this book to ensure the
accuracy of the information presented. However, the information contained in
this book is sold without warranty, either express or implied. Neither the
author, nor Packt Publishing, and its dealers and distributors will be held
liable for any damages caused or alleged to be caused directly or indirectly
by this book.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK
ISBN: 978-1-80512-730-7
www.packt.com
Table of Contents
1. React and React Native, Fifth Edition: Build cross-platform JavaScript
and TypeScript apps for the web, desktop, and mobile
2. 1 Why React?
I. Before you begin: Join our book community on Discord
II. What is React?
III. React is just the view layer
IV. Simplicity is good
V. Declarative UI structures
VI. Data changes over time
VII. Performance matters
VIII. The right level of abstraction
IX. What's new in React?
X. Setup a new React project
i. Using Web Bundlers
ii. Using Frameworks
iii. Online Code Editors
XI. Summary
3. 2 Rendering with JSX
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Your first JSX content
i. Hello JSX
ii. Declarative UI structures
IV. Rendering HTML
i. Built-in HTML tags
ii. HTML tag conventions
iii. Describing UI structures
V. Creating your own JSX elements
i. Encapsulating HTML
ii. Nested elements
iii. Namespaced components
VI. Using JavaScript expressions
i. Dynamic property values and text
ii. Handling events
iii. Mapping collections to elements
VII. Building fragments of JSX
i. Using wrapper elements
ii. Using fragments
VIII. Summary
4. 3 Understanding React Components and Hooks
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Introduction to React Components
IV. What are component properties?
i. Passing property values
ii. Default property values
V. What is component state?
VI. React Hooks
VII. Maintaining state using Hooks
i. Initial state values
ii. Updating state values
VIII. Performing initialization and cleanup actions
i. Fetching component data
ii. Canceling actions and resetting state
iii. Optimizing side-effect actions
IX. Sharing data using context Hooks
X. Memoization with Hooks
i. useMemo Hook
ii. useCallback Hook
iii. useRef Hook
XI. Summary
5. 4 Event Handling, the React Way
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Declaring event handlers
i. Declaring handler functions
ii. Multiple event handlers
IV. Declaring inline event handlers
V. Binding handlers to elements
VI. Using synthetic event objects
VII. Understanding event pooling
VIII. Summary
6. 5 Crafting Reusable Components
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Reusable HTML elements
IV. The difficulty with monolithic components
i. The JSX markup
ii. Initial state
iii. Event handler implementation
V. Refactoring component structures
i. Starting with the JSX
ii. Implementing an article list component
iii. Implementing an article item component
iv. Implementing an add article component
VI. Render props
VII. Rendering component trees
VIII. Feature components and utility components
IX. Summary
7. 6 Type Checking and Validation with TypeScript
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Knowing What to Expect
i. The Importance of Props Validation
ii. Potential Issues Without Proper Validation
iii. Options for Props Validation
IV. Introduction to TypeScript
i. Why Use TypeScript?
ii. Setting Up TypeScript in a Project
iii. Basic Types in TypeScript
iv. Interfaces and Type Aliases
V. Comparing PropTypes and TypeScript
VI. Using TypeScript in React
i. Type Checking Props in React Components
ii. Typing State
iii. Typing Event Handlers
iv. Typing Context
v. Typing Refs
VII. Summary
8. 7 Handling Navigation with Routes
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Declaring routes
i. Hello route
ii. Decoupling route declarations
IV. Handling route parameters
i. Resource IDs in routes
ii. Query parameters
V. Using link components
i. Basic linking
ii. URL and query parameters
VI. Summary
9. 8 Code Splitting Using Lazy Components and Suspense
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Using the lazy API
i. Dynamic imports and bundles
ii. Making components lazy
IV. Using the Suspense component
i. Top-level Suspense components
ii. Working with spinner fallbacks
V. Avoiding lazy components
VI. Exploring lazy pages and routes
VII. Summary
10. 9 User Interface Framework Components
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Layout and organization
i. Using containers
ii. Building responsive grid layouts
IV. Using navigation components
i. Navigating with drawers
ii. Navigating with tabs
V. Collecting user input
i. Checkboxes and radio buttons
ii. Text inputs and select inputs
iii. Working with buttons
VI. Working with styles and themes
i. Making styles
ii. Customizing themes
VII. Summary
11. 10 High-Performance State Updates
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Batching state updates
IV. Prioritizing state updates
V. Handling asynchronous state updates
VI. Summary
12. 15 Why React Native?
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. What is React Native?
IV. React and JSX are familiar
V. The mobile browser experiences
VI. Android and iOS – different yet the same
VII. The case for mobile web apps
VIII. Summary
13. 16 React Native under the Hood
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Exploring React Native architecture
i. The state of web and mobile apps in the past
ii. React Native current architecture
iii. React Native future architecture
IV. Explaining JS and Native modules
i. React Navigation
ii. UI component libraries
iii. Splash screen
iv. Icons
v. Handling errors
vi. Push notifications
vii. Over the air updates
viii. JS libraries
V. Exploring React Native components and APIs
VI. Summary
14. 17 Kick-Starting React Native Projects
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Exploring React Native CLI tools
IV. Installing and using the Expo command-line tool
V. Viewing your app on your phone
VI. Viewing your app on Expo Snack
VII. Summary
15. 18 Building Responsive Layouts with Flexbox
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Introducing Flexbox
IV. Introducing React Native styles
V. Using the Styled Components library
VI. Building Flexbox layouts
i. Simple three-column layout
ii. Improved three-column layout
iii. Flexible rows
iv. Flexible grids
v. Flexible rows and columns
VII. Summary
16. 19 Navigating Between Screens
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Navigation basics
IV. Route parameters
V. The navigation header
VI. Tab and drawer navigation
VII. File-based navigation
VIII. Summary
17. 20 Rendering Item Lists
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Rendering data collections
IV. Sorting and filtering lists
V. Fetching list data
VI. Lazy list loading
VII. Implementing pull to refresh
VIII. Summary
18. 21 Showing Progress
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Understanding progress and usability
IV. Indicating progress
V. Measuring progress
VI. Exploring navigation indicators
VII. Step progress
VIII. Summary
19. 22 Geolocation and Maps
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Using Location API
IV. Rendering the Map
V. Annotating points of interest
i. Plotting points
ii. Plotting overlays
VI. Summary
20. 23 Collecting User Input
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Collecting text input
IV. Selecting from a list of options
V. Toggling between on and off
VI. Collecting date/time input
VII. Summary
21. 24 Displaying Modal Screens
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Important information
IV. Getting user confirmation
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
i. Displaying a success confirmation
V. Error confirmation
VI. Passive notifications
VII. Activity modals
VIII. Summary
22. 25 Responding to User Gestures
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Scrolling with your fingers
IV. Giving touch feedback
V. Using Swipeable and cancellable components
VI. Summary
23. 26 Using Animations
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Using React Native Reanimated
i. Animated API
ii. React Native Reanimated
IV. Installing the React Native Reanimated library
V. Animating layout components
VI. Animating styling components
VII. Summary
24. 27 Controlling Image Display
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Loading images
IV. Resizing images
V. Lazy image loading
VI. Rendering icons
VII. Summary
25. 29 Selecting Native UI Components Using Tamagui
I. Before you begin: Join our book community on Discord
II. Technical requirements
III. Application containers
IV. Headers and footers
V. Using layout components
VI. Collecting input using form components
VII. Summary
VIII. Further reading
React and React Native, Fifth
Edition: Build cross-platform
JavaScript and TypeScript apps for
the web, desktop, and mobile
Welcome to Packt Early Access. We’re giving you an exclusive preview of
this book before it goes on sale. It can take many months to write a book, but
our authors have cutting-edge information to share with you today. Early
Access gives you an insight into the latest developments by making chapter
drafts available. The chapters may be a little rough around the edges right
now, but our authors will update them over time.You can dip in and out
of this book or follow along from start to finish; Early Access is designed to
be flexible. We hope you enjoy getting to know more about the process of
writing a Packt book.
https://packt.link/EarlyAccess
If you're reading this book, you probably know what React is. If not, don't
worry. I'll do my best to keep philosophical definitions to a minimum.
However, this is a long book with a lot of content, so I feel that setting the
tone is an appropriate first step. Yes, the goal is to learn React and React
Native. But it's also to put together a lasting architecture that can handle
everything we want to build with React today and in the future.This chapter
starts with a brief explanation of why React exists. Then, we'll think about
the simplicity of React and how it is able to handle many of the typical
performance issues faced by web developers. Next, we'll go over the
declarative philosophy of React and the level of abstraction that React
programmers can expect to work with. Finally, we'll touch on some of the
major features of React.Once you have a conceptual understanding of React
and how it solves problems with UI development, you'll be better equipped
to tackle the remainder of the book. This chapter will cover the following
topics:
What is React?
React features
What's new in React?
Setting up a new React project
What is React?
I think the one-line description of React on its home page (https://react.dev/)
is concise and accurate:
It's a library for building User Interfaces (UIs). This is perfect because, as
it turns out, this is all we want most of the time. I think the best part about this
description is everything that it leaves out. It's not a mega framework. It's not
a full-stack solution that's going to handle everything from the database to
real-time updates over WebSocket connections. We might not actually want
most of these prepackaged solutions. If React isn't a framework, then what is
it exactly?
This is all there is to React – the core concept. Of course, there will be
subtle variations to this theme as we make our way through the book, but the
flow is more or less the same. We have some application logic that generates
some data. We want to render this data to the UI, so we pass it to a React
Component, which handles the job of getting the HTML into the page.You
may wonder what the big deal is; React appears to be yet another rendering
technology. We'll touch on some of the key areas where React can simplify
application development in the remaining sections of the chapter.
Simplicity is good
React doesn't have many moving parts to learn about and understand.
Internally, there's a lot going on, and we'll touch on these things throughout
the book. The advantage of having a small API to work with is that you can
spend more time familiarizing yourself with it, experimenting with it, and so
on. The opposite is true of large frameworks, where all of your time is
devoted to figuring out how everything works. The following diagram gives
you a rough idea of the APIs that we have to think about when programming
with React:
The React Component API: These are the parts of the page that are
rendered by the React DOM.
React DOM: This is the API that's used to perform the rendering on a
web page.
Don't fixate on what these different areas of the React API represent just yet.
The takeaway here is that React, by nature, is simple. Just look at how little
there is to figure out! This means that we don't have to spend a ton of time
going through API details here. Instead, once you pick up on the basics, we
can spend more time on nuanced React usage patterns that fit in nicely with
declarative UI structures.
Declarative UI structures
React newcomers have a hard time getting to grips with the idea that
components mix in markup with their JavaScript in order to declare UI
structures. If you've looked at React examples and had the same adverse
reaction, don't worry. Initially, we're all skeptical of this approach, and I
think the reason is that we've been conditioned for decades by the separation
of concerns principle. This principle states that different concerns, such as
logic and presentation, should be separate from one another. Now, whenever
we see things mixed together, we automatically assume that this is bad and
shouldn't happen.The syntax used by React components is called JSX
(JavaScript XML). A component renders content by returning some JSX. The
JSX itself is usually HTML markup, mixed with custom tags for React
components. The specifics don't matter at this point; we'll go into detail in the
coming chapters. What's groundbreaking about the declarative JSX approach
is that we don't have to perform little micro-operations to change the content
of a component.
IMPORTANT NOTE
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Exploring the Variety of Random
Documents with Different Content
English Tongue, as spoken and
written;
above 100,000 words, or 50,000
more than
in any existing work, by the same,
3 vols. in 1 36 46 50
————, with the Grammar 56 60
14. GRAMMAR OF THE GREEK LANGUAGE,
by H. C. Hamilton 10
15, 16. DICTIONARY OF THE GREEK AND
English Languages, by H. R.
Hamilton,
2 vols. in 1 20
17, 18. DICTIONARY OF THE ENGLISH
and Greek Languages, by the
same,
2 vols. in 1 20
———— GREEK AND ENGLISH
and English and Greek, 4 vols. in 1 50 56
————, with the Greek Grammar 60 66
19. GRAMMAR of THE LATIN LANGUAGE,
by the Rev. T. Goodwin, A.B. 10
20, 21. DICTIONARY OF THE LATIN AND
English Languages, by the same.
20
Vol. I.
22, 23. DICTIONARY OF THE ENGLISH
and Latin Languages,
by the same. Vol. II. 16
————, 2 vols. in 1 46 50
————, with the Latin Grammar 56 60
24. GRAMMAR OF THE FRENCH
LANGUAGE,
by the Lecturer at Besançon. 10
25. DICTIONARY OF THE FRENCH AND
English Languages, by A. Elwes.
10
Vol. I.
26. DICTIONARY OF THE ENGLISH AND
French Languages, by the same.
16
Vol. II.
————, 2 vols. in 1 36 40
————, with the French Grammar 46 50
27. GRAMMAR OF THE ITALIAN
LANGUAGE,
by the same. 10
28, 29. DICTIONARY OF THE ITALIAN,
English, and French Languages, by
the same.
Vol. I. 20
30, 31. DICTIONARY OF THE ENGLISH,
Italian, and French Languages, by
the same.
Vol. II. 20
32, 33. DICTIONARY OF THE FRENCH,
Italian, and English Languages, by
the same.
Vol. III. 20
————, 3 vols. in 1 76 86
————, with the Italian Grammar 86 96
34. GRAMMAR OF THE SPANISH
LANGUAGE,
by the same. 10
35, 36, 37, 38. DICTIONARY OF THE
Spanish and English Languages, by
the same,
4 vols. in 1 40 50 56
————, with the Spanish Grammar 60 66
39. GRAMMAR OF THE GERMAN
LANGUAGE,
by the Lecturer at Besançon. 10
40. CLASSICAL GERMAN READER,
from the best authors, by the
10
same.
41, 42, 43. DICTIONARIES of the
ENGLISH,
German, and French Languages,
by N. E. Hamilton, 3 vols.,
separately 1s.each 30 40 46
————, with the German Grammar. 50 56
44, 45. DICTIONARY OF THE HEBREW
and English Languages, containing
the
Biblical and Rabbinical words, 2 vols.
(together with the Grammar, which
may
be had separately for 1s.)
by Dr. Bresslau, Hebrew Professor. 70
46. DICTIONARY OF THE ENGLISH AND
Hebrew Languages. Vol. III. to
complete,
by the same. 30
————, 3 vols. as 2 12 0 14 0
47. FRENCH AND ENGLISH PHRASE Book 10 1 6
Now in the course of Publication.
GREEK AND LATIN CLASSICS.
A Series of Volumes containing the principal Greek and Latin
Authors, accompanied by Explanatory Notes in English, principally
selected from the best and most recent German Commentators, and
comprising all those Works that are essential for the Scholar and the
Pupil, and applicable for the Universities of Oxford, Cambridge,
Edinburgh, Glasgow, Aberdeen, and Dublin; the Colleges at Belfast,
Cork, Galway, Winchester, and Eton; and the great Schools at
Harrow, Rugby, &c.—also for Private Tuition and Instruction, and for
the Library.
LATIN SERIES.
GREEK SERIES,
ON A SIMILAR PLAN TO THE LATIN SERIES.
Transcriber's Notes:
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
ebookmasss.com