The GameForm component

The GameForm component used in both the NewGame and EditGame components contains the elements that allow users to enter game details and VR object details for a single game. It may start with a blank game object or load an existing game in componentDidMount.

mern-vrgame/client/game/GameForm.js:

state = {    game: {name: '', clue:'', world:'', answerObjects:[], wrongObjects:[]},    redirect: false,    readError: ''  }

If the GameForm component receives a gameId prop from the parent component, such as from the EditGame component, then it will use the read API to retrieve the game's details and set it to state to be rendered in the form view.

mern-vrgame/client/game/GameForm.js:

componentDidMount = () => { if(this.props.gameId){ ...

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.