Skip to Main Content
React Projects
book

React Projects

by Roy Derks
December 2019
Intermediate to advanced content levelIntermediate to advanced
474 pages
10h 3m
English
Packt Publishing
Content preview from React Projects

Routes with parameters

With the first route in place, other routes can be added to the router component. A logical one is having a route for individual questions, that has an extra parameter that specifies which question should be displayed. Therefore, a new container component called Question must be created, which contains the logic for fetching a question from the Stack Overflow API. This component is rendered when the path matches /question/:id, where id stands for the ID of the question that is clicked on from the feed:

  1. Create a new class component called Question in the src/containers directory, and add a constructor and render method to this file:
import React, { Component } from 'react';import styled from 'styled-components';const ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

React Projects - Second Edition

React Projects - Second Edition

Roy Derks
Test-Driven React

Test-Driven React

Trevor Burnham

Publisher Resources

ISBN: 9781789954937Supplemental Content