Adding a new object to the array

The button to add an object will allow users to add a new VRObjectForm component to take the details of a new VR object.

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

addObject = name => event => {    const newGame = this.state.game     newGame[name].push({})     this.setState({game: newGame}) } 

This will basically just add an empty object to the array being iterated with a call to the addObject method with the array type specified in the name value.

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.