Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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 Projects

You're reading from   React Projects Build advanced cross-platform projects with React and React Native to become a professional developer

Arrow left icon
Product type Paperback
Published in Apr 2022
Publisher Packt
ISBN-13 9781801070638
Length 384 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Roy Derks Roy Derks
Author Profile Icon Roy Derks
Roy Derks
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Chapter 1: Creating a Single-Page Application in React 2. Chapter 2: Creating a Portfolio in React with Reusable Components and Routing FREE CHAPTER 3. Chapter 3: Building a Dynamic Project Management Board 4. Chapter 4: Building a Server-Side-Rendered Community Feed Using Next.js 5. Chapter 5: Building a Personal Shopping List Application Using Context and Hooks 6. Chapter 6: Building an Application Exploring TDD Using the React Testing Library and Cypress 7. Chapter 7: Building a Full-Stack E-Commerce Application with Next.js and GraphQL 8. Chapter 8: Building an Animated Game Using React Native and Expo 9. Chapter 9: Building a Full-Stack Social Media Application with React Native and Expo 10. Chapter 10: Creating a Virtual Reality Application with React and Three.js 11. Other Books You May Enjoy

Routing with Next.js

With the react-router package, we can add declarative routing to any React application, but you need to set up components that define which routes you want to add. With Next.js, the filesystem is being used for routing, starting at the pages directory. Every file and directory in pages can represent a route. You can check this by visiting the project at http://localhost:3000, where the contents of index.js are being rendered.

If we, for example, wanted to add the new /questions route to the application, we'd need to create either a new file called questions.js or a directory called questions with an index.js file in pages. Let's go with the second option and add the following code to this file:

import styled from 'styled-components';
const QuestionsContainer = styled.div'
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  margin: 5%;
';
function Questions() ...
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