Game list views
Visitors to MERN VR Game will access the games on the application from lists rendered on the home page and individual user profiles. The home page will list all the games on the application, and the games by a specific maker will be listed on their user profile page. The list views will iterate through game data fetched using the list
APIs and render details of each game in the GameDetail
component.
All games
The Home
component will fetch the list of all the games in the game collection using the list API when the component mounts.
mern-vrgame/client/core/Home.js
:
componentDidMount = () => { list().then((data) => { if (data.error) { console.log(data.error) } else { this.setState({games: data}) } }) }
The list of games retrieved from the server will be set to state and iterated over to render a GameDetail
component with each game in the list.
mern-vrgame/client/core/Home.js
:
{this.state.games.map((game, i) => { return <...