Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
React and React Native

You're reading from   React and React Native Build cross-platform JavaScript applications with native power for the web, desktop, and mobile

Arrow left icon
Product type Paperback
Published in May 2022
Publisher Packt
ISBN-13 9781803231280
Length 606 pages
Edition 4th Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Roy Derks Roy Derks
Author Profile Icon Roy Derks
Roy Derks
Mikhail Sakhniuk Mikhail Sakhniuk
Author Profile Icon Mikhail Sakhniuk
Mikhail Sakhniuk
Adam Boduch Adam Boduch
Author Profile Icon Adam Boduch
Adam Boduch
Arrow right icon
View More author details
Toc

Table of Contents (36) Chapters Close

Preface 1. Part 1 – React
2. Chapter 1: Why React? FREE CHAPTER 3. Chapter 2: Rendering with JSX 4. Chapter 3: Component Properties, State, and Context 5. Chapter 4: Getting Started with Hooks 6. Chapter 5: Event Handling, the React Way 7. Chapter 6: Crafting Reusable Components 8. Chapter 7: The React Component Life Cycle 9. Chapter 8: Validating Component Properties 10. Chapter 9: Handling Navigation with Routes 11. Chapter 10: Code Splitting Using Lazy Components and Suspense 12. Chapter 11: Server-Side React Components 13. Chapter 12: User Interface Framework Components 14. Chapter 13: High-Performance State Updates 15. Part 2 – React Native
16. Chapter 14: Why React Native? 17. Chapter 15: React Native under the Hood 18. Chapter 16: Kick-Starting React Native Projects 19. Chapter 17: Building Responsive Layouts with Flexbox 20. Chapter 18: Navigating Between Screens 21. Chapter 19: Rendering Item Lists 22. Chapter 20: Showing Progress 23. Chapter 21: Geolocation and Maps 24. Chapter 22: Collecting User Input 25. Chapter 23: Displaying Modal Screens 26. Chapter 24: Responding to User Gestures 27. Chapter 25: Using Animations 28. Chapter 26: Controlling Image Display 29. Chapter 27: Going Offline 30. Chapter 28: Selecting Native UI Components Using NativeBase 31. Part 3 – React Architecture
32. Chapter 29: Handling Application State 33. Chapter 30: Why GraphQL? 34. Chapter 31: Building a GraphQL React App 35. Other Books You May Enjoy

Using link components

In this section, you'll learn how to create links. You might be tempted to use the standard <a> elements to link to pages controlled by react-router. The problem with this approach is that these links will try to locate the page on the backend by sending a GET request. This isn't what you want because the route configuration is already in the browser.

First, you'll see an example that illustrates how <Link> elements are just like <a> elements in most ways. Then, you'll see how to build links that use URL parameters and query parameters.

Basic linking

The idea of links in React apps is that they point to routes that point to components, which render new content. The Link component also takes care of the browser history API and looks up route-component mappings. Here's an application component that renders two links:

import * as React from "react";
import {
  BrowserRouter as Router,
 ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime