Book Image

Full-Stack React Projects

By : Shama Hoque
Book Image

Full-Stack React Projects

By: Shama Hoque

Overview of this book

The benefits of using a full JavaScript stack for web development are undeniable, especially when robust and widely adopted technologies such as React, Node, and Express and are available. Combining the power of React with industry-tested, server-side technologies, such as Node, Express, and MongoDB, creates a diverse array of possibilities when developing real-world web applications. This book guides you through preparing the development environment for MERN stack-based web development, to creating a basic skeleton application and extending it to build four different web applications. These applications include a social media, an online marketplace, a media streaming, and a web-based game application with virtual reality features. While learning to set up the stack and developing a diverse range of applications with this book, you will grasp the inner workings of the MERN stack, extend its capabilities for complex features, and gain actionable knowledge of how to prepare MERN-based applications to meet the growing demands of real-world web applications.
Table of Contents (19 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Updating the game code in React 360


With the game backend all set up in the MERN application, we can update the React 360 project code we developed in Chapter 10Developing a Web-Based VR Game, to make it render games directly from the game collection in the database.

We will use the game ID in the link that opens the React 360 application to fetch game details with the read API from within the React 360 code, and then set the data to state so the game loads details retrieved from the database instead of the static sample data we used in Chapter 10Developing a Web-Based VR Game.

Once the code is updated, we can bundle it again and place the compiled files in the MERN application.

Getting the game ID from a link

In the index.js file of the React 360 project folder, update the componentDidMount method to retrieve the game ID from the incoming URL and make a fetch call to the read game API.

/MERNVR/index.js:

componentDidMount = () => {
    let gameId = Location.search.split('?id=')[1]
read...