3. Conditional Rendering and for Loops
Activity 3.01: Building a Board Game Using Conditional Rendering
Solution:
- First, start off by creating your new React project (as we have done so many times before). As per usual, delete
src/logo.svg
, and then change theimport
statements insrc/App.js
to importReact
and theComponent
class from React. Do not delete theimport
statement forsrc/App.css
. Insrc/App.js
, the code should look like this:import React, { Component } from 'react'; import './App.css'; class App extends Component { Â Â render() { Â Â return ( Â Â Â Â <div className="App"> Â Â Â Â Â Â <h1>Memory Game</h1> Â Â Â Â </div> Â Â ); Â Â } } export default App;
The CSS that we used here is as follows:
.Tile { width: 200px; height: 200px; font-size: 64pt; border: 2px solid #aaa; text-align: center; margin: 10px; padding: 10px; float...